comparison svr-main.c @ 1052:e40d1b63b6a6 coverity

merge
author Matt Johnston <matt@ucc.asn.au>
date Sat, 28 Feb 2015 23:25:16 +0800
parents a00303a7d247
children 2265d7ebfdeb
comparison
equal deleted inserted replaced
1046:b8f4b7027191 1052:e40d1b63b6a6
136 { 136 {
137 dropbear_exit("No listening ports available."); 137 dropbear_exit("No listening ports available.");
138 } 138 }
139 139
140 for (i = 0; i < listensockcount; i++) { 140 for (i = 0; i < listensockcount; i++) {
141 set_sock_priority(listensocks[i], DROPBEAR_PRIO_LOWDELAY);
142 FD_SET(listensocks[i], &fds); 141 FD_SET(listensocks[i], &fds);
143 } 142 }
144 143
145 /* fork */ 144 /* fork */
146 if (svr_opts.forkbg) { 145 if (svr_opts.forkbg) {
401 400
402 seedrandom(); 401 seedrandom();
403 } 402 }
404 403
405 /* Set up listening sockets for all the requested ports */ 404 /* Set up listening sockets for all the requested ports */
406 static size_t listensockets(int *sock, size_t sockcount, int *maxfd) { 405 static size_t listensockets(int *socks, size_t sockcount, int *maxfd) {
407 406
408 unsigned int i; 407 unsigned int i, n;
409 char* errstring = NULL; 408 char* errstring = NULL;
410 size_t sockpos = 0; 409 size_t sockpos = 0;
411 int nsock; 410 int nsock;
412 411
413 TRACE(("listensockets: %d to try", svr_opts.portcount)) 412 TRACE(("listensockets: %d to try", svr_opts.portcount))
414 413
415 for (i = 0; i < svr_opts.portcount; i++) { 414 for (i = 0; i < svr_opts.portcount; i++) {
416 415
417 TRACE(("listening on '%s:%s'", svr_opts.addresses[i], svr_opts.ports[i])) 416 TRACE(("listening on '%s:%s'", svr_opts.addresses[i], svr_opts.ports[i]))
418 417
419 nsock = dropbear_listen(svr_opts.addresses[i], svr_opts.ports[i], &sock[sockpos], 418 nsock = dropbear_listen(svr_opts.addresses[i], svr_opts.ports[i], &socks[sockpos],
420 sockcount - sockpos, 419 sockcount - sockpos,
421 &errstring, maxfd); 420 &errstring, maxfd);
422 421
423 if (nsock < 0) { 422 if (nsock < 0) {
424 dropbear_log(LOG_WARNING, "Failed listening on '%s': %s", 423 dropbear_log(LOG_WARNING, "Failed listening on '%s': %s",
425 svr_opts.ports[i], errstring); 424 svr_opts.ports[i], errstring);
426 m_free(errstring); 425 m_free(errstring);
427 continue; 426 continue;
428 } 427 }
429 428
429 for (n = 0; n < (unsigned int)nsock; n++) {
430 int sock = socks[sockpos + n];
431 set_sock_priority(sock, DROPBEAR_PRIO_LOWDELAY);
432 #ifdef DROPBEAR_TCP_FAST_OPEN
433 set_listen_fast_open(sock);
434 #endif
435 }
436
430 sockpos += nsock; 437 sockpos += nsock;
431 438
432 } 439 }
433 return sockpos; 440 return sockpos;
434 } 441 }