From: Gerrit Renker Date: Mon, 17 Dec 2007 12:12:25 +0000 (+0100) Subject: 01_DCCP_shutdown-unnecessary.diff X-Git-Tag: v0.3.0~48 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=73f02f72cb49baebff3e0f6946750a5bc0693321;p=paraslash.git 01_DCCP_shutdown-unnecessary.diff This calls shutdown(2) for unused communication paths in the DCCP sender/receiver: * the sender does not read data from the client and so calls shutdown(SHUT_RD); * the client does not send data to the server and so calls shutdown(SHUT_WR). The advantage that this buys is a performance optimisation: using shutdown(2) in DCCP means disabling the corresponding CCID kernel modules, which reduces the processing costs, i.e. * when using SHUT_RD, the receiver congestion-control module is de-activated; * when using SHUT_WR, the sender congestion-control module is de-activated. More information can be found on http://www.erg.abdn.ac.uk/users/gerrit/dccp/notes/shutdown/ --- diff --git a/dccp_recv.c b/dccp_recv.c index eeb7c57a..c0618602 100644 --- a/dccp_recv.c +++ b/dccp_recv.c @@ -61,6 +61,13 @@ static int dccp_recv_open(struct receiver_node *rn) if (ret < 0) return ret; + /* + * Disable unused CCIDs: the receiver does not send any application data to the + * server. By shutting down this unused path we reduce internal processing costs, + * as the unused CCIDs (in the kernel) are then bypassed. + */ + if (shutdown(ret, SHUT_WR) < 0) + return -ERRNO_TO_PARA_ERROR(errno); rn->buf = para_calloc(DCCP_BUFSIZE); rn->private_data = pdd = para_calloc(sizeof(struct private_dccp_recv_data)); diff --git a/dccp_send.c b/dccp_send.c index 5d8e6593..f3b9120b 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -72,6 +72,15 @@ static void dccp_post_select(fd_set *rfds, __a_unused fd_set *wfds) PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); return; } + /* + * Bypass unused CCID paths: the sender does not receive application data + * from the client; by shutting down this unused communication path we can + * reduce processing costs a bit. See analogous comment in dccp_recv.c. + */ + if (shutdown(ret, SHUT_RD) < 0) { + PARA_ERROR_LOG("shutdown(SHUT_RD): %s\n", strerror(errno)); + return; + } dc = para_calloc(sizeof(struct dccp_client)); dc->fd = ret; dc->name = make_message("%s", remote_name(dc->fd));