/[imapfilter]/imapfilter/socket.c
ViewVC logotype

Diff of /imapfilter/socket.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by lefcha, Fri Nov 9 15:50:30 2001 UTC revision 1.8 by lefcha, Fri Nov 9 16:55:15 2001 UTC
# Line 62  int init_connection(char *serv, unsigned Line 62  int init_connection(char *serv, unsigned
62    
63  #ifdef SSL_TLS  #ifdef SSL_TLS
64      if (protocol != SSL_DISABLED) {      if (protocol != SSL_DISABLED) {
65          ssl_init(protocol);          if (!ssl_init(protocol)) {
66          info("Connected to %s using %s.\n", serv, SSL_get_cipher(ssl));              info("Connected to %s using %s.\n", serv, SSL_get_cipher(ssl));
67      } else {              return 0;
68            }
69        } else
70          ssl = NULL;          ssl = NULL;
71  #endif  #endif
         info("Connected to %s.\n", serv);  
 #ifdef SSL_TLS  
     }  
 #endif  
   
72    
73        info("Connected to %s.\n", serv);
74        
75      return 0;      return 0;
76  }  }
77    
# Line 181  int socket_read(char *buf) Line 180  int socket_read(char *buf)
180      fd_set fds;      fd_set fds;
181      struct timeval tv;      struct timeval tv;
182    
183      r = s = 0;      r = 0;
184        s = 1;
185    
186      memset(buf, 0, RESPONSE_BUF);      memset(buf, 0, RESPONSE_BUF);
187    
188      tv.tv_sec = 30;      tv.tv_sec = 60;
189      tv.tv_usec = 0;      tv.tv_usec = 0;
190    
191      flags = fcntl(sock, F_GETFL, 0);      flags = fcntl(sock, F_GETFL, 0);
# Line 196  int socket_read(char *buf) Line 196  int socket_read(char *buf)
196    
197  #ifdef SSL_TLS  #ifdef SSL_TLS
198      if (ssl) {      if (ssl) {
199          if (SSL_pending(ssl) || ((s = select(sock + 1, &fds, NULL, NULL, &tv)) > 0          if (SSL_pending(ssl)
200                                   && FD_ISSET(sock, &fds)))              || ((s = select(sock + 1, &fds, NULL, NULL, &tv)) > 0
201                    && FD_ISSET(sock, &fds)))
202              r = SSL_read(ssl, buf, RESPONSE_BUF - 1);              r = SSL_read(ssl, buf, RESPONSE_BUF - 1);
203      } else      } else
204  #endif  #endif
# Line 207  int socket_read(char *buf) Line 208  int socket_read(char *buf)
208    
209      fcntl(sock, F_SETFL, flags);      fcntl(sock, F_SETFL, flags);
210    
211      if (s <= 0)      if (s == -1)
212          fatal(ERROR_NETWORK, "imapfilter: waiting input from socket; %s\n",          fatal(ERROR_NETWORK, "imapfilter: waiting input from socket; %s\n",
213                strerror(errno));                strerror(errno));
214        else if (!s)
215            fatal(ERROR_NETWORK,
216                  "imapfilter: timeout period expired while waiting data\n");
217    
218  #ifdef SSL_TLS  #ifdef SSL_TLS
219      if (ssl) {      if (ssl) {
220          if (r <= 0)          if (r < 0)
221              fatal(ERROR_NETWORK, "imapfilter: reading data; %s",              fatal(ERROR_NETWORK, "imapfilter: reading data; %s",
222                    ERR_error_string(r, NULL));                    ERR_error_string(r, NULL));
223      } else      } else

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26