summaryrefslogtreecommitdiffstats
path: root/sesman/chansrv/devredir.c
diff options
context:
space:
mode:
authorLaxmikant Rashinkar <LK.Rashinkar@gmail.com>2013-06-02 15:33:51 -0700
committerLaxmikant Rashinkar <LK.Rashinkar@gmail.com>2013-06-02 15:33:51 -0700
commit2029867510c1556deeedfeb03ed052bbbaaf6d88 (patch)
tree878c53d23944586c8d5b0baa356a7dbafea4b47a /sesman/chansrv/devredir.c
parent62a4403dd408f86f6a5d7e9750a2f213e6b95224 (diff)
downloadxrdp-proprietary-2029867510c1556deeedfeb03ed052bbbaaf6d88.tar.gz
xrdp-proprietary-2029867510c1556deeedfeb03ed052bbbaaf6d88.zip
folder redirection: made changes to read/write routines to avoid race conditions
Diffstat (limited to 'sesman/chansrv/devredir.c')
-rw-r--r--sesman/chansrv/devredir.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c
index 08f28a0d..77f1569f 100644
--- a/sesman/chansrv/devredir.c
+++ b/sesman/chansrv/devredir.c
@@ -775,16 +775,24 @@ void dev_redir_proc_device_iocompletion(struct stream *s)
log_debug("got CID_READ");
xstream_rd_u32_le(s, Length);
fuse_data = devredir_fuse_data_dequeue(irp);
+
if (fuse_data == NULL)
log_error("fuse_data is NULL");
+
xfuse_devredir_cb_read_file(fuse_data->data_ptr, s->p, Length);
+ devredir_irp_delete(irp);
break;
case CID_WRITE:
log_debug("got CID_WRITE");
xstream_rd_u32_le(s, Length);
fuse_data = devredir_fuse_data_dequeue(irp);
+
+ if (fuse_data == NULL)
+ log_error("fuse_data is NULL");
+
xfuse_devredir_cb_write_file(fuse_data->data_ptr, s->p, Length);
+ devredir_irp_delete(irp);
break;
case CID_CLOSE:
@@ -1172,11 +1180,12 @@ int devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode)
* @return 0 on success, -1 on failure
*****************************************************************************/
-int dev_redir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
+int devredir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
tui32 Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
+ IRP *new_irp;
int bytes;
xstream_new(s, 1024);
@@ -1188,12 +1197,22 @@ int dev_redir_file_read(void *fusep, tui32 DeviceId, tui32 FileId,
return -1;
}
- irp->completion_type = CID_READ;
- devredir_fuse_data_enqueue(irp, fusep);
+ /* create a new IRP for this request */
+ if ((new_irp = devredir_irp_clone(irp)) == NULL)
+ {
+ /* system out of memory */
+ xfuse_devredir_cb_read_file(fusep, NULL, 0);
+ return -1;
+ }
+ new_irp->FileId = 0;
+ new_irp->completion_type = CID_READ;
+ new_irp->CompletionId = g_completion_id++;
+ devredir_fuse_data_enqueue(new_irp, fusep);
+
devredir_insert_DeviceIoRequest(s,
DeviceId,
FileId,
- irp->CompletionId,
+ new_irp->CompletionId,
IRP_MJ_READ,
0);
@@ -1214,6 +1233,7 @@ int dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
{
struct stream *s;
IRP *irp;
+ IRP *new_irp;
int bytes;
log_debug("DeviceId=%d FileId=%d Length=%d Offset=%lld",
@@ -1228,12 +1248,22 @@ int dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId,
return -1;
}
- irp->completion_type = CID_WRITE;
- devredir_fuse_data_enqueue(irp, fusep);
+ /* create a new IRP for this request */
+ if ((new_irp = devredir_irp_clone(irp)) == NULL)
+ {
+ /* system out of memory */
+ xfuse_devredir_cb_write_file(fusep, NULL, 0);
+ return -1;
+ }
+ new_irp->FileId = 0;
+ new_irp->completion_type = CID_WRITE;
+ new_irp->CompletionId = g_completion_id++;
+ devredir_fuse_data_enqueue(new_irp, fusep);
+
devredir_insert_DeviceIoRequest(s,
DeviceId,
FileId,
- irp->CompletionId,
+ new_irp->CompletionId,
IRP_MJ_WRITE,
0);