tcp: Bring back MSG_EOF flag support in sosendtcp()
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 4 Nov 2011 14:01:32 +0000 (22:01 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 4 Nov 2011 14:03:38 +0000 (22:03 +0800)
Though it was originally designed for T/TCP, it is nice to have

While I'm here, clean up the 'async' setting

sys/kern/uipc_socket.c

index 2af3c65..c5dfd89 100644 (file)
@@ -942,20 +942,24 @@ restart:
                        ++cnt;
                    } while (space > 0 && cnt < tcp_sosnd_agglim);
 
+                   if (tcp_sosnd_async)
+                           async = 1;
+
                    if (flags & MSG_OOB) {
                            pru_flags = PRUS_OOB;
+                           async = 0;
+                   } else if ((flags & MSG_EOF) && resid == 0) {
+                           pru_flags = PRUS_EOF;
                    } else if (resid > 0 && space > 0) {
                            /* If there is more to send, set PRUS_MORETOCOME */
                            pru_flags = PRUS_MORETOCOME;
                            async = 1;
                    } else {
                            pru_flags = 0;
-                           if (tcp_sosnd_async)
-                               async = 1;
                    }
 
                    if (flags & MSG_SYNC)
-                       async = 0;
+                           async = 0;
 
                    /*
                     * XXX all the SS_CANTSENDMORE checks previously