1
fix: don't close invalid sockets
3
From 512c7ca2732118149c3ee4b23980fe03d29077b2 Mon Sep 17 00:00:00 2001
4
From: Howard Chu <hyc@openldap.org>
5
Date: Wed, 21 Jul 2010 23:41:17 +0000
10
libraries/liblber/sockbuf.c | 11 +++++++----
11
1 files changed, 7 insertions(+), 4 deletions(-)
13
diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c
14
index e1d9e45..5bd0a1d 100644
15
--- a/libraries/liblber/sockbuf.c
16
+++ b/libraries/liblber/sockbuf.c
17
@@ -541,7 +541,8 @@ sb_stream_close( Sockbuf_IO_Desc *sbiod )
19
assert( sbiod != NULL );
20
assert( SOCKBUF_VALID( sbiod->sbiod_sb ) );
21
- tcp_close( sbiod->sbiod_sb->sb_fd );
22
+ if ( sbiod->sbiod_sb->sb_fd != AC_SOCKET_INVALID )
23
+ tcp_close( sbiod->sbiod_sb->sb_fd );
27
@@ -754,7 +755,8 @@ sb_fd_close( Sockbuf_IO_Desc *sbiod )
28
assert( sbiod != NULL );
29
assert( SOCKBUF_VALID( sbiod->sbiod_sb ) );
31
- close( sbiod->sbiod_sb->sb_fd );
32
+ if ( sbiod->sbiod_sb->sb_fd != AC_SOCKET_INVALID )
33
+ close( sbiod->sbiod_sb->sb_fd );
37
@@ -956,8 +958,9 @@ sb_dgram_close( Sockbuf_IO_Desc *sbiod )
39
assert( sbiod != NULL );
40
assert( SOCKBUF_VALID( sbiod->sbiod_sb ) );
42
- tcp_close( sbiod->sbiod_sb->sb_fd );
44
+ if ( sbiod->sbiod_sb->sb_fd != AC_SOCKET_INVALID )
45
+ tcp_close( sbiod->sbiod_sb->sb_fd );