CVS: rdesktop disk.c,1.18,1.19 rdpdr.c,1.22,1.23 types.h,1.17,1.18

Peter Bystr?m <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14660

Modified Files:
	disk.c rdpdr.c types.h 
Log Message:
move disk info define to types.h
extract aio remove
handle errors in aio read / write
function that checks if handle is ok - seems windows cant keep track of them huh
- volker milde


Index: disk.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/disk.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** disk.c	28 Feb 2004 10:52:29 -0000	1.18
--- disk.c	4 Mar 2004 08:24:40 -0000	1.19
***************
*** 134,147 ****
  extern RDPDR_DEVICE g_rdpdr_device[];
  
! struct fileinfo
! {
! 	uint32 device_id, flags_and_attributes;
! 	char path[256];
! 	DIR *pdir;
! 	struct dirent *pdirent;
! 	char pattern[64];
! 	BOOL delete_on_close;
! }
! g_fileinfo[MAX_OPEN_FILES];
  
  typedef struct
--- 134,138 ----
  extern RDPDR_DEVICE g_rdpdr_device[];
  
! FILEINFO g_fileinfo[MAX_OPEN_FILES];
  
  typedef struct

Index: rdpdr.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpdr.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** rdpdr.c	23 Feb 2004 12:07:30 -0000	1.22
--- rdpdr.c	4 Mar 2004 08:24:40 -0000	1.23
***************
*** 2,5 ****
--- 2,6 ----
  #include <sys/types.h>
  #include <sys/time.h>
+ #include <dirent.h>		/* opendir, closedir, readdir */
  #include <time.h>
  #include "rdesktop.h"
***************
*** 29,32 ****
--- 30,34 ----
  extern DEVICE_FNS parallel_fns;
  extern DEVICE_FNS disk_fns;
+ extern FILEINFO g_fileinfo[];
  
  static VCHANNEL *rdpdr_channel;
***************
*** 80,83 ****
--- 82,105 ----
  }
  
+ BOOL
+ rdpdr_handle_ok(int device, int handle)
+ {
+ 	switch (g_rdpdr_device[device].device_type)
+ 	{
+ 		case DEVICE_TYPE_PARALLEL:
+ 		case DEVICE_TYPE_SERIAL:
+ 		case DEVICE_TYPE_PRINTER:
+ 		case DEVICE_TYPE_SCARD:
+ 			if (g_rdpdr_device[device].handle != handle)
+ 				return False;
+ 			break;
+ 		case DEVICE_TYPE_DISK:
+ 			if (g_fileinfo[handle].device_id != device)
+ 				return False;
+ 			break;
+ 	}
+ 	return True;
+ }
+ 
  /* Add a new io request to the table containing pending io requests so it won't block rdesktop */
  BOOL
***************
*** 392,395 ****
--- 414,423 ----
  			DEBUG(("RDPDR IRP Read (length: %d, offset: %d)\n", length, offset));
  #endif
+ 			if (!rdpdr_handle_ok(device, file))
+ 			{
+ 				status = STATUS_INVALID_HANDLE;
+ 				break;
+ 			}
+ 
  			if (rw_blocking)	// Complete read immediately
  			{
***************
*** 439,442 ****
--- 467,476 ----
  			DEBUG(("RDPDR IRP Write (length: %d)\n", result));
  #endif
+ 			if (!rdpdr_handle_ok(device, file))
+ 			{
+ 				status = STATUS_INVALID_HANDLE;
+ 				break;
+ 			}
+ 
  			if (rw_blocking)	// Complete immediately
  			{
***************
*** 758,761 ****
--- 792,818 ----
  }
  
+ struct async_iorequest *
+ rdpdr_remove_iorequest(struct async_iorequest *prev, struct async_iorequest *iorq)
+ {
+ 	if (!iorq)
+ 		return NULL;
+ 
+ 	if (iorq->buffer)
+ 		xfree(iorq->buffer);
+ 	if (prev)
+ 	{
+ 		prev->next = iorq->next;
+ 		xfree(iorq);
+ 		iorq = prev->next;
+ 	}
+ 	else
+ 	{
+ 		// Even if NULL
+ 		g_iorequest = iorq->next;
+ 		xfree(iorq);
+ 		iorq = NULL;
+ 	}
+ 	return iorq;
+ }
  
  /* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */
***************
*** 798,804 ****
  								   iorq->buffer + iorq->partial_len,
  								   req_size, iorq->offset, &result);
- 						iorq->partial_len += result;
- 						iorq->offset += result;
  
  #if WITH_DEBUG_RDP5
  						DEBUG(("RDPDR: %d bytes of data read\n", result));
--- 855,864 ----
  								   iorq->buffer + iorq->partial_len,
  								   req_size, iorq->offset, &result);
  
+ 						if (result > 0)
+ 						{
+ 							iorq->partial_len += result;
+ 							iorq->offset += result;
+ 						}
  #if WITH_DEBUG_RDP5
  						DEBUG(("RDPDR: %d bytes of data read\n", result));
***************
*** 812,817 ****
  							DEBUG(("RDPDR: AIO total %u bytes read of %u\n", iorq->partial_len, iorq->length));
  #endif
- 							/* send the data */
- 							status = STATUS_SUCCESS;
  							rdpdr_send_completion(iorq->device,
  									      iorq->id, status,
--- 872,875 ----
***************
*** 819,837 ****
  									      iorq->buffer,
  									      iorq->partial_len);
! 							xfree(iorq->buffer);
! 							iorq->fd = 0;
! 							if (prev != NULL)
! 							{
! 								prev->next = iorq->next;
! 								xfree(iorq);
! 								iorq = prev->next;
! 							}
! 							else
! 							{
! 								// Even if NULL
! 								g_iorequest = iorq->next;
! 								xfree(iorq);
! 								iorq = NULL;
! 							}
  						}
  					}
--- 877,881 ----
  									      iorq->buffer,
  									      iorq->partial_len);
! 							iorq = rdpdr_remove_iorequest(prev, iorq);
  						}
  					}
***************
*** 853,858 ****
  								    iorq->partial_len, req_size,
  								    iorq->offset, &result);
! 						iorq->partial_len += result;
! 						iorq->offset += result;
  #if WITH_DEBUG_RDP5
  						DEBUG(("RDPDR: %d bytes of data written\n",
--- 897,907 ----
  								    iorq->partial_len, req_size,
  								    iorq->offset, &result);
! 
! 						if (result > 0)
! 						{
! 							iorq->partial_len += result;
! 							iorq->offset += result;
! 						}
! 
  #if WITH_DEBUG_RDP5
  						DEBUG(("RDPDR: %d bytes of data written\n",
***************
*** 867,872 ****
  							DEBUG(("RDPDR: AIO total %u bytes written of %u\n", iorq->partial_len, iorq->length));
  #endif
- 							/* send a status success */
- 							status = STATUS_SUCCESS;
  							rdpdr_send_completion(iorq->device,
  									      iorq->id, status,
--- 916,919 ----
***************
*** 874,892 ****
  									      (uint8 *) "", 1);
  
! 							xfree(iorq->buffer);
! 							iorq->fd = 0;
! 							if (prev != NULL)
! 							{
! 								prev->next = iorq->next;
! 								xfree(iorq);
! 								iorq = prev->next;
! 							}
! 							else
! 							{
! 								// Even if NULL
! 								g_iorequest = iorq->next;
! 								xfree(iorq);
! 								iorq = NULL;
! 							}
  						}
  					}
--- 921,925 ----
  									      (uint8 *) "", 1);
  
! 							iorq = rdpdr_remove_iorequest(prev, iorq);
  						}
  					}
***************
*** 921,937 ****
  			rdpdr_send_completion(iorq->device, iorq->id, status, result, (uint8 *) "",
  					      1);
! 			xfree(iorq->buffer);
! 			iorq->fd = 0;
! 			if (prev != NULL)
! 			{
! 				prev->next = iorq->next;
! 				xfree(iorq);
! 			}
! 			else
! 			{
! 				// Even if NULL
! 				g_iorequest = iorq->next;
! 				xfree(iorq);
! 			}
  			return True;
  		}
--- 954,959 ----
  			rdpdr_send_completion(iorq->device, iorq->id, status, result, (uint8 *) "",
  					      1);
! 
! 			iorq = rdpdr_remove_iorequest(prev, iorq);
  			return True;
  		}

Index: types.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/types.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** types.h	23 Jan 2004 08:35:51 -0000	1.17
--- types.h	4 Mar 2004 08:24:40 -0000	1.18
***************
*** 167,170 ****
--- 167,171 ----
  {
  	int dtr;
+ 	int rts;
  	uint32 baud_rate,
  		queue_in_size,
***************
*** 204,205 ****
--- 205,217 ----
  }
  PRINTER;
+ 
+ typedef struct fileinfo
+ {
+ 	uint32 device_id, flags_and_attributes;
+ 	char path[256];
+ 	DIR *pdir;
+ 	struct dirent *pdirent;
+ 	char pattern[64];
+ 	BOOL delete_on_close;
+ }
+ FILEINFO;



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.