comparison dbutil.c @ 279:1f5ec029dfe8

merge of 4c883eb469d2d251ee8abddbc11ae4005db6da17 and bed6155e95a293c9fce7e889d283b5958f3035dc
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 12:53:11 +0000
parents 044bc108b9b3
children 79bf1023cf11 973fccb59ea4 e17f0333c21e 28b10e93685c
comparison
equal deleted inserted replaced
278:e109fb08b8ee 279:1f5ec029dfe8
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