Changeset 5537

Show
Ignore:
Timestamp:
05/28/08 01:23:41 (4 months ago)
Author:
morris
Message:

wi_socket_wait_descriptor() no longer sets error, do it ourselves in functions that can time out

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/libwired/net/wi-socket.c

    r5530 r5537  
    11691169wi_boolean_t wi_socket_accept_tls(wi_socket_t *socket, wi_socket_tls_t *tls, wi_time_interval_t timeout) { 
    11701170#ifdef WI_SSL 
    1171         SSL             *ssl; 
     1171        SSL                                     *ssl; 
     1172        wi_socket_state_t       state; 
    11721173         
    11731174        ssl = SSL_new(tls->ssl_ctx); 
     
    11941195         
    11951196        if(timeout > 0.0) { 
    1196                 if(wi_socket_wait_descriptor(socket->sd, timeout, true, false) != WI_SOCKET_READY) 
     1197                state = wi_socket_wait_descriptor(socket->sd, timeout, true, false); 
     1198                 
     1199                if(state != WI_SOCKET_READY) { 
     1200                        if(state == WI_SOCKET_TIMEOUT) 
     1201                                wi_error_set_errno(ETIMEDOUT); 
     1202                         
    11971203                        goto err; 
     1204                } 
    11981205        } 
    11991206 
     
    13561363 
    13571364wi_integer_t wi_socket_write_buffer(wi_socket_t *socket, wi_time_interval_t timeout, const void *buffer, size_t length) { 
    1358         wi_integer_t    bytes; 
     1365        wi_socket_state_t       state; 
     1366        wi_integer_t            bytes; 
    13591367         
    13601368        if(timeout > 0.0) { 
    1361                 if(wi_socket_wait_descriptor(socket->sd, timeout, false, true) != WI_SOCKET_READY) 
     1369                state = wi_socket_wait_descriptor(socket->sd, timeout, false, true); 
     1370 
     1371                if(state != WI_SOCKET_READY) { 
     1372                        if(state == WI_SOCKET_TIMEOUT) 
     1373                                wi_error_set_errno(ETIMEDOUT); 
     1374                         
    13621375                        return -1; 
     1376                } 
    13631377        } 
    13641378 
     
    14731487 
    14741488wi_integer_t wi_socket_read_buffer(wi_socket_t *socket, wi_time_interval_t timeout, void *buffer, size_t length) { 
    1475         wi_integer_t    bytes; 
     1489        wi_socket_state_t       state; 
     1490        wi_integer_t            bytes; 
    14761491         
    14771492        if(timeout > 0.0) { 
     
    14791494                if(!socket->ssl || (socket->ssl && SSL_pending(socket->ssl) == 0)) { 
    14801495#endif 
    1481                         if(wi_socket_wait_descriptor(socket->sd, timeout, true, false) != WI_SOCKET_READY) 
     1496                        state = wi_socket_wait_descriptor(socket->sd, timeout, true, false); 
     1497 
     1498                        if(state != WI_SOCKET_READY) { 
     1499                                if(state == WI_SOCKET_TIMEOUT) 
     1500                                        wi_error_set_errno(ETIMEDOUT); 
     1501                                 
    14821502                                return -1; 
     1503                        } 
    14831504#ifdef WI_SSL 
    14841505                }