comparison dbutil.c @ 277:044bc108b9b3

* Per-IP connection unauthed connection limits * m_close() exits fatally on failure * other cleanups
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 12:41:27 +0000
parents 306499676384
children 79bf1023cf11 973fccb59ea4 e17f0333c21e 28b10e93685c
comparison
equal deleted inserted replaced
266:e37b160c414c 277:044bc108b9b3
586 } 586 }
587 587
588 } 588 }
589 #endif 589 #endif
590 590
591 /* loop until the socket is closed (in case of EINTR) or 591 /* make sure that the socket closes */
592 * we get and error. 592 void m_close(int fd) {
593 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
594 int m_close(int fd) {
595 593
596 int val; 594 int val;
597 do { 595 do {
598 val = close(fd); 596 val = close(fd);
599 } while (val < 0 && errno == EINTR); 597 } while (val < 0 && errno == EINTR);
600 598
601 if (val == 0 || errno == EBADF) { 599 if (val < 0 && errno != EBADF) {
602 return DROPBEAR_SUCCESS; 600 /* Linux says EIO can happen */
603 } else { 601 dropbear_exit("Error closing fd %d, %s", fd, strerror(errno));
604 return DROPBEAR_FAILURE;
605 } 602 }
606 } 603 }
607 604
608 void * m_malloc(size_t size) { 605 void * m_malloc(size_t size) {
609 606