Mercurial > dropbear
comparison common-session.c @ 416:a01c0c8e543a channel-fix
Improve behaviour when flushing out after a process has exited.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 09 Feb 2007 10:43:16 +0000 |
parents | 70caa99bfe3a |
children | 9c61e7af0156 |
comparison
equal
deleted
inserted
replaced
415:8b9aba1d5fa4 | 416:a01c0c8e543a |
---|---|
59 ses.sock = sock; | 59 ses.sock = sock; |
60 ses.maxfd = sock; | 60 ses.maxfd = sock; |
61 | 61 |
62 ses.connecttimeout = 0; | 62 ses.connecttimeout = 0; |
63 | 63 |
64 if (pipe(ses.signal_pipe) < 0) { | |
65 dropbear_exit("signal pipe failed"); | |
66 } | |
67 setnonblocking(ses.signal_pipe[0]); | |
68 setnonblocking(ses.signal_pipe[1]); | |
69 | |
64 kexfirstinitialise(); /* initialise the kex state */ | 70 kexfirstinitialise(); /* initialise the kex state */ |
65 | 71 |
66 ses.writepayload = buf_new(MAX_TRANS_PAYLOAD_LEN); | 72 ses.writepayload = buf_new(MAX_TRANS_PAYLOAD_LEN); |
67 ses.transseq = 0; | 73 ses.transseq = 0; |
68 | 74 |
105 ses.remoteident = NULL; | 111 ses.remoteident = NULL; |
106 | 112 |
107 ses.chantypes = NULL; | 113 ses.chantypes = NULL; |
108 | 114 |
109 ses.allowprivport = 0; | 115 ses.allowprivport = 0; |
110 | |
111 | 116 |
112 TRACE(("leave session_init")) | 117 TRACE(("leave session_init")) |
113 } | 118 } |
114 | 119 |
115 void session_loop(void(*loophandler)()) { | 120 void session_loop(void(*loophandler)()) { |
130 FD_SET(ses.sock, &readfd); | 135 FD_SET(ses.sock, &readfd); |
131 if (!isempty(&ses.writequeue)) { | 136 if (!isempty(&ses.writequeue)) { |
132 FD_SET(ses.sock, &writefd); | 137 FD_SET(ses.sock, &writefd); |
133 } | 138 } |
134 } | 139 } |
140 | |
141 /* We get woken up when signal handlers write to this pipe. | |
142 SIGCHLD in svr-chansession is the only one currently. */ | |
143 FD_SET(ses.signal_pipe[0], &readfd); | |
135 | 144 |
136 /* set up for channels which require reading/writing */ | 145 /* set up for channels which require reading/writing */ |
137 if (ses.dataallowed) { | 146 if (ses.dataallowed) { |
138 setchannelfds(&readfd, &writefd); | 147 setchannelfds(&readfd, &writefd); |
139 } | 148 } |
152 * want to iterate over channels etc for reading, to handle | 161 * want to iterate over channels etc for reading, to handle |
153 * server processes exiting etc. | 162 * server processes exiting etc. |
154 * We don't want to read/write FDs. */ | 163 * We don't want to read/write FDs. */ |
155 FD_ZERO(&writefd); | 164 FD_ZERO(&writefd); |
156 FD_ZERO(&readfd); | 165 FD_ZERO(&readfd); |
166 } | |
167 | |
168 /* We'll just empty out the pipe if required. We don't do | |
169 any thing with the data, since the pipe's purpose is purely to | |
170 wake up the select() above. */ | |
171 if (FD_ISSET(ses.signal_pipe[0], &readfd)) { | |
172 char x; | |
173 while (read(ses.signal_pipe[0], &x, 1) > 0) {} | |
157 } | 174 } |
158 | 175 |
159 /* check for auth timeout, rekeying required etc */ | 176 /* check for auth timeout, rekeying required etc */ |
160 checktimeouts(); | 177 checktimeouts(); |
161 | 178 |