/[rdesktop]/sourceforge.net/trunk/rdesktop/rdpdr.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/rdpdr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 592 by n-ki, Fri Jan 30 14:10:32 2004 UTC revision 595 by n-ki, Tue Feb 3 14:02:59 2004 UTC
# Line 49  struct async_iorequest Line 49  struct async_iorequest
49          DEVICE_FNS *fns;          DEVICE_FNS *fns;
50    
51          struct async_iorequest *next;   /* next element in list */          struct async_iorequest *next;   /* next element in list */
52  } g_iorequest;  };
53    
54    struct async_iorequest *g_iorequest;
55    
56  /* Return device_id for a given handle */  /* Return device_id for a given handle */
57  int  int
# Line 83  add_async_iorequest(uint32 device, uint3 Line 85  add_async_iorequest(uint32 device, uint3
85  {  {
86          struct async_iorequest *iorq;          struct async_iorequest *iorq;
87    
88          iorq = &g_iorequest;          if (g_iorequest == NULL)
         while (iorq->fd != 0)  
89          {          {
90                  // create new element if needed                  g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
91                  if (iorq->next == NULL)                  g_iorequest->fd = 0;
92                          iorq->next =                  g_iorequest->next = NULL;
                                 (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));  
   
                 iorq = iorq->next;  
93          }          }
94    
95          /* first element is special since it doesn't get deleted */          iorq = g_iorequest;
96          /* don't want to get io out of order */  
97          if (g_iorequest.fd == 0)          while (iorq->fd != 0)
98          {          {
99                  iorq = &g_iorequest;                  // create new element if needed
100                  /* look for first occurrence of fd */                  if (iorq->next == NULL)
                 while (iorq->next != NULL)  
                 {  
                         if (iorq->fd == file)  
                                 break;  
                         iorq = iorq->next;  
                 }  
                 /* if same create new link at end of chain instead */  
                 if (iorq->fd == file)  
101                  {                  {
                         while (iorq->next != NULL)  
                                 iorq = iorq->next;  
102                          iorq->next =                          iorq->next =
103                                  (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));                                  (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
104                          iorq = iorq->next;                          iorq->next->fd = 0;
105                            iorq->next->next = NULL;
106                  }                  }
107                  else                  iorq = iorq->next;
                         iorq = &g_iorequest;    /* didn't find fs use first entry */  
108          }          }
   
109          iorq->device = device;          iorq->device = device;
110          iorq->fd = file;          iorq->fd = file;
111          iorq->id = id;          iorq->id = id;
# Line 329  rdpdr_process_irp(STREAM s) Line 316  rdpdr_process_irp(STREAM s)
316    
317                  case DEVICE_TYPE_DISK:                  case DEVICE_TYPE_DISK:
318    
                         /*rw_blocking = False; */  
319                          fns = &disk_fns;                          fns = &disk_fns;
320                            rw_blocking = False;
321                          break;                          break;
322    
323                  case DEVICE_TYPE_SCARD:                  case DEVICE_TYPE_SCARD:
# Line 702  rdpdr_add_fds(int *n, fd_set * rfds, fd_ Line 689  rdpdr_add_fds(int *n, fd_set * rfds, fd_
689          long select_timeout = 0;        // Timeout value to be used for select() (in millisecons).          long select_timeout = 0;        // Timeout value to be used for select() (in millisecons).
690          struct async_iorequest *iorq;          struct async_iorequest *iorq;
691    
692          iorq = &g_iorequest;          iorq = g_iorequest;
693          while (iorq != NULL)          while (iorq != NULL)
694          {          {
695                  if (iorq->fd != 0)                  if (iorq->fd != 0)
# Line 749  rdpdr_check_fds(fd_set * rfds, fd_set * Line 736  rdpdr_check_fds(fd_set * rfds, fd_set *
736          DEVICE_FNS *fns;          DEVICE_FNS *fns;
737          struct async_iorequest *iorq;          struct async_iorequest *iorq;
738          struct async_iorequest *prev;          struct async_iorequest *prev;
739            uint32 req_size = 0;
740    
741          if (timed_out)          if (timed_out)
742          {          {
# Line 756  rdpdr_check_fds(fd_set * rfds, fd_set * Line 744  rdpdr_check_fds(fd_set * rfds, fd_set *
744                  return;                  return;
745          }          }
746    
747          iorq = &g_iorequest;          iorq = g_iorequest;
748          prev = NULL;          prev = NULL;
749          while (iorq != NULL)          while (iorq != NULL)
750          {          {
   
751                  if (iorq->fd != 0)                  if (iorq->fd != 0)
752                  {                  {
753                          switch (iorq->major)                          switch (iorq->major)
# Line 770  rdpdr_check_fds(fd_set * rfds, fd_set * Line 757  rdpdr_check_fds(fd_set * rfds, fd_set *
757                                          {                                          {
758                                                  /* Read the data */                                                  /* Read the data */
759                                                  fns = iorq->fns;                                                  fns = iorq->fns;
760    
761                                                    req_size =
762                                                            (iorq->length - iorq->partial_len) >
763                                                            8192 ? 8192 : (iorq->length -
764                                                                           iorq->partial_len);
765                                                    /* never read larger chunks than 8k - chances are that it will block */
766                                                  status = fns->read(iorq->fd,                                                  status = fns->read(iorq->fd,
767                                                                     iorq->buffer + iorq->partial_len,                                                                     iorq->buffer + iorq->partial_len,
768                                                                     iorq->length - iorq->partial_len,                                                                     req_size, 0, &result);
                                                                    0, &result);  
769                                                  iorq->partial_len += result;                                                  iorq->partial_len += result;
770    
771  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
772                                                  DEBUG(("RDPDR: %d bytes of data read\n", result));                                                  DEBUG(("RDPDR: %d bytes of data read\n", result));
773  #endif  #endif
774                                                  /* only delete link if all data has been transfered */                                                  /* only delete link if all data has been transfered */
775                                                  if (iorq->partial_len == iorq->length)                                                  /* or if result was 0 and status success - EOF      */
776                                                    if ((iorq->partial_len == iorq->length) ||
777                                                        (result == 0))
778                                                  {                                                  {
779    #if WITH_DEBUG_RDP5
780                                                            DEBUG(("RDPDR: AIO total %u bytes read of %u\n", iorq->partial_len, iorq->length));
781    #endif
782                                                          /* send the data */                                                          /* send the data */
783                                                          status = STATUS_SUCCESS;                                                          status = STATUS_SUCCESS;
784                                                          rdpdr_send_completion(iorq->device,                                                          rdpdr_send_completion(iorq->device,
785                                                                                iorq->id, status,                                                                                iorq->id, status,
786                                                                                iorq->length,                                                                                iorq->partial_len,
787                                                                                iorq->buffer, result);                                                                                iorq->buffer,
788                                                                                  iorq->partial_len);
789                                                          xfree(iorq->buffer);                                                          xfree(iorq->buffer);
790                                                          iorq->fd = 0;                                                          iorq->fd = 0;
791                                                          if (prev != NULL)                                                          if (prev != NULL)
# Line 795  rdpdr_check_fds(fd_set * rfds, fd_set * Line 793  rdpdr_check_fds(fd_set * rfds, fd_set *
793                                                                  prev->next = iorq->next;                                                                  prev->next = iorq->next;
794                                                                  xfree(iorq);                                                                  xfree(iorq);
795                                                          }                                                          }
796                                                            else
797                                                            {
798                                                                    // Even if NULL
799                                                                    g_iorequest = iorq->next;
800                                                                    xfree(iorq);
801                                                            }
802                                                  }                                                  }
803                                          }                                          }
804                                          break;                                          break;
# Line 803  rdpdr_check_fds(fd_set * rfds, fd_set * Line 807  rdpdr_check_fds(fd_set * rfds, fd_set *
807                                          {                                          {
808                                                  /* Write data. */                                                  /* Write data. */
809                                                  fns = iorq->fns;                                                  fns = iorq->fns;
810    
811                                                    req_size =
812                                                            (iorq->length - iorq->partial_len) >
813                                                            8192 ? 8192 : (iorq->length -
814                                                                           iorq->partial_len);
815    
816                                                    /* never write larger chunks than 8k - chances are that it will block */
817                                                  status = fns->write(iorq->fd,                                                  status = fns->write(iorq->fd,
818                                                                      iorq->buffer +                                                                      iorq->buffer +
819                                                                      iorq->partial_len,                                                                      iorq->partial_len, req_size, 0,
820                                                                      iorq->length -                                                                      &result);
                                                                     iorq->partial_len, 0, &result);  
821                                                  iorq->partial_len += result;                                                  iorq->partial_len += result;
822  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
823                                                  DEBUG(("RDPDR: %d bytes of data written\n",                                                  DEBUG(("RDPDR: %d bytes of data written\n",
824                                                         result));                                                         result));
825  #endif  #endif
826                                                  /* only delete link if all data has been transfered */                                                  /* only delete link if all data has been transfered */
827                                                  if (iorq->partial_len == iorq->length)                                                  /* or we couldn't write */
828                                                    if ((iorq->partial_len == iorq->length)
829                                                        || (result == 0))
830                                                  {                                                  {
831    #if WITH_DEBUG_RDP5
832                                                            DEBUG(("RDPDR: AIO total %u bytes written of %u\n", iorq->partial_len, iorq->length));
833    #endif
834                                                          /* send a status success */                                                          /* send a status success */
835                                                          status = STATUS_SUCCESS;                                                          status = STATUS_SUCCESS;
836                                                          rdpdr_send_completion(iorq->device,                                                          rdpdr_send_completion(iorq->device,
837                                                                                iorq->id, status,                                                                                iorq->id, status,
838                                                                                iorq->length, "", 1);                                                                                iorq->partial_len, "",
839                                                                                  1);
840    
841                                                          xfree(iorq->buffer);                                                          xfree(iorq->buffer);
842                                                          iorq->fd = 0;                                                          iorq->fd = 0;
# Line 829  rdpdr_check_fds(fd_set * rfds, fd_set * Line 845  rdpdr_check_fds(fd_set * rfds, fd_set *
845                                                                  prev->next = iorq->next;                                                                  prev->next = iorq->next;
846                                                                  xfree(iorq);                                                                  xfree(iorq);
847                                                          }                                                          }
848                                                            else
849                                                            {
850                                                                    // Even if NULL
851                                                                    g_iorequest = iorq->next;
852                                                                    xfree(iorq);
853                                                            }
854                                                  }                                                  }
855                                          }                                          }
856                                          break;                                          break;
# Line 866  rdpdr_abort_io(uint32 fd, uint32 major, Line 888  rdpdr_abort_io(uint32 fd, uint32 major,
888                                  prev->next = iorq->next;                                  prev->next = iorq->next;
889                                  xfree(iorq);                                  xfree(iorq);
890                          }                          }
891                            else
892                            {
893                                    // Even if NULL
894                                    g_iorequest = iorq->next;
895                                    xfree(iorq);
896                            }
897                          return True;                          return True;
898                  }                  }
899    

Legend:
Removed from v.592  
changed lines
  Added in v.595

  ViewVC Help
Powered by ViewVC 1.1.26