@@ -193,53 +193,48 @@ int acl_socket_read(ACL_SOCKET fd, void *buf, size_t size,
193193int acl_socket_write (ACL_SOCKET fd , const void * buf , size_t size ,
194194 int timeout , ACL_VSTREAM * fp acl_unused , void * arg acl_unused )
195195{
196- #if 0
197- WSABUF wsaData ;
198- DWORD dwBytes = 0 ;
199- int ret ;
200-
201- wsaData .len = (u_long ) size ;
202- wsaData .buf = (char * ) buf ;
196+ int ret , error ;
203197
204- ret = WSASend (fd , & wsaData , 1 , & dwBytes , 0 , NULL , NULL );
205- if (ret == SOCKET_ERROR ) {
206- return ( -1 ) ;
198+ ret = __sys_send (fd , buf , ( int ) size , 0 );
199+ if (ret > 0 ) {
200+ return ret ;
207201 }
208- return dwBytes ;
209- #else
210- int ret ;
211202
212- #ifdef ACL_WRITEABLE_CHECK
213- if (timeout > 0 && acl_write_wait (fd , timeout ) < 0 ) {
203+ if (timeout <= 0 ) {
214204 errno = acl_last_error ();
215- return -1 ;
205+ return ret ;
216206 }
207+
208+ error = acl_last_error ();
209+
210+ #if ACL_EWOULDBLOCK == ACL_EAGAIN
211+ if (error != ACL_EWOULDBLOCK ) {
217212#else
218- ( void ) timeout ;
213+ if ( error != ACL_EWOULDBLOCK && error != ACL_EAGAIN ) {
219214#endif
215+ return ret ;
216+ }
220217
221- ret = __sys_send (fd , buf , (int ) size , 0 );
222- if (ret <= 0 ) {
223- errno = acl_last_error ();
218+ #ifdef ACL_WRITEABLE_CHECK
219+ if (fp != NULL && ACL_VSTREAM_IS_MS (fp )) {
220+ if (acl_write_wait_ms (fd , timeout ) < 0 ) {
221+ return -1 ;
222+ }
223+ } else if (acl_write_wait (fd , timeout ) < 0 ) {
224+ return -1 ;
224225 }
226+
227+ return __sys_send (fd , buf , (int ) size , 0 );
228+ #else
225229 return ret ;
226230#endif
227231}
228232
229233int acl_socket_writev (ACL_SOCKET fd , const struct iovec * vec , int count ,
230- int timeout , ACL_VSTREAM * fp acl_unused , void * arg acl_unused )
234+ int timeout acl_unused , ACL_VSTREAM * fp acl_unused , void * arg acl_unused )
231235{
232236 int i , n , ret ;
233237
234- #ifdef ACL_WRITEABLE_CHECK
235- if (timeout > 0 && acl_write_wait (fd , timeout ) < 0 ) {
236- errno = acl_last_error ();
237- return -1 ;
238- }
239- #else
240- (void ) timeout ;
241- #endif
242-
243238 n = 0 ;
244239 for (i = 0 ; i < count ; i ++ ) {
245240 ret = __sys_send (fd , vec [i ].iov_base , (int ) vec [i ].iov_len , 0 );
0 commit comments