Commit a19fb42e449ac0d830c23a4c6d1f484e1858aaf7

Thomas de Grivel 2017-06-20T22:22:55

shutdown socket before close

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/cffi-socket.lisp b/cffi-socket.lisp
index 86ada58..3791843 100644
--- a/cffi-socket.lisp
+++ b/cffi-socket.lisp
@@ -37,6 +37,7 @@
 (defmacro with-socket ((var domain type protocol) &body body)
   `(let ((,var (socket ,domain ,type ,protocol)))
      (unwind-protect (progn ,@body)
+       (shutdown ,var t t)
        (unistd:close ,var))))
 
 (defcstruct sockaddr
@@ -135,6 +136,7 @@
   `(multiple-value-bind (,fd-var ,addr-var) (accept ,listening-fd)
      (when ,fd-var
        (unwind-protect (progn ,@body)
+         (shutdown ,fd-var t t)
 	 (unistd:close ,fd-var)))))
 
 (defcfun ("recv" c-recv) ssize-t