commit 340bfcc4a84a658da8e62071879b19f40d6f6d32
parent 3e3cf3ac9a3bc03a562a2361a6eda126423a12d8
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Mon, 20 Mar 2006 20:34:32 +0000
handle socket() failure and correctly report gethostbyname() failure.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/drv_imap.c b/src/drv_imap.c
@@ -1265,7 +1265,7 @@ imap_open_store( store_conf_t *conf )
infon( "Resolving %s... ", srvc->host );
he = gethostbyname( srvc->host );
if (!he) {
- perror( "gethostbyname" );
+ error( "IMAP error: Cannot resolve server '%s'\n", srvc->host );
goto bail;
}
info( "ok\n" );
@@ -1273,6 +1273,10 @@ imap_open_store( store_conf_t *conf )
addr.sin_addr.s_addr = *((int *) he->h_addr_list[0]);
s = socket( PF_INET, SOCK_STREAM, 0 );
+ if (s < 0) {
+ perror( "socket" );
+ exit( 1 );
+ }
infon( "Connecting to %s:%hu... ", inet_ntoa( addr.sin_addr ), ntohs( addr.sin_port ) );
if (connect( s, (struct sockaddr *)&addr, sizeof(addr) )) {