X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=libraries%2Fliblber%2Fsockbuf.c;h=0d1c513b9bcda930aba4fe0c059e59384c3e1249;hb=cba0d05a9dfd3cad69380e3ee2b492ddd7c7ca84;hp=a828d078302a9f37aeaf03d4ae5bec04186b835c;hpb=c6df30118faef4b7b0461d161a2cc10b494b9eed;p=openldap diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index a828d07830..0d1c513b9b 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2007 The OpenLDAP Foundation. + * Copyright 1998-2011 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -339,7 +339,7 @@ ber_pvt_sb_do_write( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out ) int ber_pvt_socket_set_nonblock( ber_socket_t sd, int nb ) { -#if HAVE_FCNTL +#ifdef HAVE_FCNTL int flags = fcntl( sd, F_GETFL); if( nb ) { flags |= O_NONBLOCK; @@ -541,7 +541,8 @@ sb_stream_close( Sockbuf_IO_Desc *sbiod ) { assert( sbiod != NULL ); assert( SOCKBUF_VALID( sbiod->sbiod_sb ) ); - tcp_close( sbiod->sbiod_sb->sb_fd ); + if ( sbiod->sbiod_sb->sb_fd != AC_SOCKET_INVALID ) + tcp_close( sbiod->sbiod_sb->sb_fd ); return 0; } @@ -724,7 +725,7 @@ sb_fd_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len ) if ( blen > len ) blen = len; AC_MEMCPY( buf, sbiod->sbiod_sb->sb_ungetbuf, blen ); - buf += blen; + buf = (char *) buf + blen; len -= blen; sbiod->sbiod_sb->sb_ungetlen -= blen; if ( sbiod->sbiod_sb->sb_ungetlen ) { @@ -754,7 +755,8 @@ sb_fd_close( Sockbuf_IO_Desc *sbiod ) assert( sbiod != NULL ); assert( SOCKBUF_VALID( sbiod->sbiod_sb ) ); - close( sbiod->sbiod_sb->sb_fd ); + if ( sbiod->sbiod_sb->sb_fd != AC_SOCKET_INVALID ) + close( sbiod->sbiod_sb->sb_fd ); return 0; } @@ -905,7 +907,7 @@ static ber_slen_t sb_dgram_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len ) { ber_slen_t rc; - socklen_t addrlen; + ber_socklen_t addrlen; struct sockaddr *src; assert( sbiod != NULL ); @@ -914,7 +916,7 @@ sb_dgram_read( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len ) addrlen = sizeof( struct sockaddr ); src = buf; - buf += addrlen; + buf = (char *) buf + addrlen; len -= addrlen; rc = recvfrom( sbiod->sbiod_sb->sb_fd, buf, len, 0, src, &addrlen ); @@ -932,7 +934,7 @@ sb_dgram_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len ) assert( buf != NULL ); dst = buf; - buf += sizeof( struct sockaddr ); + buf = (char *) buf + sizeof( struct sockaddr ); len -= sizeof( struct sockaddr ); rc = sendto( sbiod->sbiod_sb->sb_fd, buf, len, 0, dst, @@ -956,8 +958,9 @@ sb_dgram_close( Sockbuf_IO_Desc *sbiod ) { assert( sbiod != NULL ); assert( SOCKBUF_VALID( sbiod->sbiod_sb ) ); - - tcp_close( sbiod->sbiod_sb->sb_fd ); + + if ( sbiod->sbiod_sb->sb_fd != AC_SOCKET_INVALID ) + tcp_close( sbiod->sbiod_sb->sb_fd ); return 0; }