Commit d0ec964e d0ec964e0e522a7d7e6edda91a970d59539de730 by Alain Magloire

ChangeLog mailbox/tcp.c

Check the return value of close(2)
1 parent b87e34b3
...@@ -62,12 +62,18 @@ static int ...@@ -62,12 +62,18 @@ static int
62 _tcp_close (stream_t stream) 62 _tcp_close (stream_t stream)
63 { 63 {
64 struct _tcp_instance *tcp = stream_get_owner (stream); 64 struct _tcp_instance *tcp = stream_get_owner (stream);
65 int err = 0;
65 66
66 if (tcp->fd != -1) 67 if (tcp->fd != -1)
67 close (tcp->fd); 68 {
69 if (close (tcp->fd) != 0)
70 {
71 err = errno;
72 }
73 }
68 tcp->fd = -1; 74 tcp->fd = -1;
69 tcp->state = TCP_STATE_INIT; 75 tcp->state = TCP_STATE_INIT;
70 return 0; 76 return err;
71 } 77 }
72 78
73 static int 79 static int
...@@ -157,7 +163,7 @@ _tcp_get_transport2 (stream_t stream, mu_transport_t *tr, mu_transport_t *tr2) ...@@ -157,7 +163,7 @@ _tcp_get_transport2 (stream_t stream, mu_transport_t *tr, mu_transport_t *tr2)
157 163
158 if (tcp->fd == -1) 164 if (tcp->fd == -1)
159 return EINVAL; 165 return EINVAL;
160 166
161 if (tr) 167 if (tr)
162 *tr = (mu_transport_t) tcp->fd; 168 *tr = (mu_transport_t) tcp->fd;
163 if (tr2) 169 if (tr2)
...@@ -266,6 +272,6 @@ tcp_stream_create (stream_t * stream, const char* host, int port, int flags) ...@@ -266,6 +272,6 @@ tcp_stream_create (stream_t * stream, const char* host, int port, int flags)
266 stream_set_get_transport2 (*stream, _tcp_get_transport2, tcp); 272 stream_set_get_transport2 (*stream, _tcp_get_transport2, tcp);
267 stream_set_destroy (*stream, _tcp_destroy, tcp); 273 stream_set_destroy (*stream, _tcp_destroy, tcp);
268 stream_set_wait (*stream, _tcp_wait, tcp); 274 stream_set_wait (*stream, _tcp_wait, tcp);
269 275
270 return 0; 276 return 0;
271 } 277 }
......