comparison common-session.c @ 1173:d734fe76b72f coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Mon, 23 Nov 2015 23:04:48 +0800
parents a550e1e2e2a9
children b370b4b172d0
comparison
equal deleted inserted replaced
1144:624fc24cfae5 1173:d734fe76b72f
157 timeout.tv_usec = 0; 157 timeout.tv_usec = 0;
158 FD_ZERO(&writefd); 158 FD_ZERO(&writefd);
159 FD_ZERO(&readfd); 159 FD_ZERO(&readfd);
160 dropbear_assert(ses.payload == NULL); 160 dropbear_assert(ses.payload == NULL);
161 161
162 /* We get woken up when signal handlers write to this pipe.
163 SIGCHLD in svr-chansession is the only one currently. */
164 FD_SET(ses.signal_pipe[0], &readfd);
165
166 /* set up for channels which can be read/written */
167 setchannelfds(&readfd, &writefd, writequeue_has_space);
168
169 /* Pending connections to test */
170 set_connect_fds(&writefd);
171
162 /* We delay reading from the input socket during initial setup until 172 /* We delay reading from the input socket during initial setup until
163 after we have written out our initial KEXINIT packet (empty writequeue). 173 after we have written out our initial KEXINIT packet (empty writequeue).
164 This means our initial packet can be in-flight while we're doing a blocking 174 This means our initial packet can be in-flight while we're doing a blocking
165 read for the remote ident. 175 read for the remote ident.
166 We also avoid reading from the socket if the writequeue is full, that avoids 176 We also avoid reading from the socket if the writequeue is full, that avoids
168 if (ses.sock_in != -1 178 if (ses.sock_in != -1
169 && (ses.remoteident || isempty(&ses.writequeue)) 179 && (ses.remoteident || isempty(&ses.writequeue))
170 && writequeue_has_space) { 180 && writequeue_has_space) {
171 FD_SET(ses.sock_in, &readfd); 181 FD_SET(ses.sock_in, &readfd);
172 } 182 }
183
184 /* Ordering is important, this test must occur after any other function
185 might have queued packets (such as connection handlers) */
173 if (ses.sock_out != -1 && !isempty(&ses.writequeue)) { 186 if (ses.sock_out != -1 && !isempty(&ses.writequeue)) {
174 FD_SET(ses.sock_out, &writefd); 187 FD_SET(ses.sock_out, &writefd);
175 } 188 }
176
177 /* We get woken up when signal handlers write to this pipe.
178 SIGCHLD in svr-chansession is the only one currently. */
179 FD_SET(ses.signal_pipe[0], &readfd);
180
181 /* set up for channels which can be read/written */
182 setchannelfds(&readfd, &writefd, writequeue_has_space);
183
184 /* Pending connections to test */
185 set_connect_fds(&writefd);
186 189
187 val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout); 190 val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout);
188 191
189 if (exitflag) { 192 if (exitflag) {
190 dropbear_exit("Terminated by signal"); 193 dropbear_exit("Terminated by signal");