comparison src/event-msw.c @ 560:b202fbfc7dea

[xemacs-hg @ 2001-05-23 11:29:58 by ben] event-msw.c: prior kludgy code was clobbering the buffer, thinking it was "unused" space to store an unneeded return value; instead, use the variable we've already got staring us in the face.
author ben
date Wed, 23 May 2001 11:30:01 +0000
parents ed498ef2108b
children 183866b06e0b
comparison
equal deleted inserted replaced
559:5101772788b2 560:b202fbfc7dea
780 the next time we get here, since we use asynchronous I/O. We have 780 the next time we get here, since we use asynchronous I/O. We have
781 in fact seen data loss as a result of not doing this. */ 781 in fact seen data loss as a result of not doing this. */
782 str->buffer = xrealloc (str->buffer, size); 782 str->buffer = xrealloc (str->buffer, size);
783 memcpy (str->buffer, data, size); 783 memcpy (str->buffer, data, size);
784 784
785 /* Docs indicate that 4th parameter to WriteFile can be NULL since this is 785 /* According to MSDN WriteFile docs, the fourth parameter cannot be NULL
786 * an overlapped operation. This fails on Win95 with winsock 1.x so we 786 on Win95 even when doing an overlapped operation, as we are, where
787 * supply a spare address which is ignored by Win95 anyway. Sheesh. */ 787 the return value through that parameter is not meaningful. */
788 if (WriteFile ((HANDLE)str->s, str->buffer, size, (LPDWORD)&str->buffer, 788 if (WriteFile ((HANDLE)str->s, str->buffer, size, &str->bufsize,
789 &str->ov) 789 &str->ov)
790 || GetLastError() == ERROR_IO_PENDING) 790 || GetLastError() == ERROR_IO_PENDING)
791 str->pending_p = 1; 791 str->pending_p = 1;
792 else 792 else
793 str->error_p = 1; 793 str->error_p = 1;
808 CloseHandle ((HANDLE)str->s); 808 CloseHandle ((HANDLE)str->s);
809 if (str->pending_p) 809 if (str->pending_p)
810 WaitForSingleObject (str->ov.hEvent, INFINITE); 810 WaitForSingleObject (str->ov.hEvent, INFINITE);
811 811
812 if (str->buffer) 812 if (str->buffer)
813 xfree (str->buffer); 813 {
814 xfree (str->buffer);
815 str->buffer = 0;
816 }
814 817
815 CloseHandle (str->ov.hEvent); 818 CloseHandle (str->ov.hEvent);
816 return 0; 819 return 0;
817 } 820 }
818 821