/[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 593 by n-ki, Mon Feb 2 07:06:55 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 756  rdpdr_check_fds(fd_set * rfds, fd_set * Line 743  rdpdr_check_fds(fd_set * rfds, fd_set *
743                  return;                  return;
744          }          }
745    
746          iorq = &g_iorequest;          iorq = g_iorequest;
747          prev = NULL;          prev = NULL;
748          while (iorq != NULL)          while (iorq != NULL)
749          {          {
# 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                                                    /* never read larger chunks than 8k - chances are that it will block */
762                                                  status = fns->read(iorq->fd,                                                  status = fns->read(iorq->fd,
763                                                                     iorq->buffer + iorq->partial_len,                                                                     iorq->buffer + iorq->partial_len,
764                                                                     iorq->length - iorq->partial_len,                                                                     (iorq->length -
765                                                                     0, &result);                                                                      iorq->partial_len) >
766                                                                       8192 ? 8192 : (iorq->length -
767                                                                                      iorq->
768                                                                                      partial_len), 0,
769                                                                       &result);
770                                                  iorq->partial_len += result;                                                  iorq->partial_len += result;
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));
# Line 795  rdpdr_check_fds(fd_set * rfds, fd_set * Line 788  rdpdr_check_fds(fd_set * rfds, fd_set *
788                                                                  prev->next = iorq->next;                                                                  prev->next = iorq->next;
789                                                                  xfree(iorq);                                                                  xfree(iorq);
790                                                          }                                                          }
791                                                            else
792                                                            {
793                                                                    // Even if NULL
794                                                                    g_iorequest = iorq->next;
795                                                                    xfree(iorq);
796                                                            }
797                                                  }                                                  }
798                                          }                                          }
799                                          break;                                          break;
# Line 803  rdpdr_check_fds(fd_set * rfds, fd_set * Line 802  rdpdr_check_fds(fd_set * rfds, fd_set *
802                                          {                                          {
803                                                  /* Write data. */                                                  /* Write data. */
804                                                  fns = iorq->fns;                                                  fns = iorq->fns;
805    
806                                                    /* never write larger chunks than 8k - chances are that it will block */
807                                                  status = fns->write(iorq->fd,                                                  status = fns->write(iorq->fd,
808                                                                      iorq->buffer +                                                                      iorq->buffer +
809                                                                      iorq->partial_len,                                                                      iorq->partial_len,
810                                                                      iorq->length -                                                                      (iorq->length -
811                                                                      iorq->partial_len, 0, &result);                                                                       iorq->partial_len) >
812                                                                        8192 ? 8192 : (iorq->length -
813                                                                                       iorq->
814                                                                                       partial_len), 0,
815                                                                        &result);
816                                                  iorq->partial_len += result;                                                  iorq->partial_len += result;
817  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
818                                                  DEBUG(("RDPDR: %d bytes of data written\n",                                                  DEBUG(("RDPDR: %d bytes of data written\n",
# Line 829  rdpdr_check_fds(fd_set * rfds, fd_set * Line 834  rdpdr_check_fds(fd_set * rfds, fd_set *
834                                                                  prev->next = iorq->next;                                                                  prev->next = iorq->next;
835                                                                  xfree(iorq);                                                                  xfree(iorq);
836                                                          }                                                          }
837                                                            else
838                                                            {
839                                                                    // Even if NULL
840                                                                    g_iorequest = iorq->next;
841                                                                    xfree(iorq);
842                                                            }
843                                                  }                                                  }
844                                          }                                          }
845                                          break;                                          break;
# Line 866  rdpdr_abort_io(uint32 fd, uint32 major, Line 877  rdpdr_abort_io(uint32 fd, uint32 major,
877                                  prev->next = iorq->next;                                  prev->next = iorq->next;
878                                  xfree(iorq);                                  xfree(iorq);
879                          }                          }
880                            else
881                            {
882                                    // Even if NULL
883                                    g_iorequest = iorq->next;
884                                    xfree(iorq);
885                            }
886                          return True;                          return True;
887                  }                  }
888    

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

  ViewVC Help
Powered by ViewVC 1.1.26