Ejemplo n.º 1
0
static void
private_fwdNegotiateSSL(int fd,void *data)
{
	SSL *ssl = fd_table[fd].ssl;
	int ret;

	server *s=(server *)data;

	//unsigned char key[22];
	errno = 0;
	ERR_clear_error();
	if ((ret = SSL_connect(ssl)) <= 0)
	{
		int ssl_error = SSL_get_error(ssl, ret);
		switch (ssl_error)
		{
			case SSL_ERROR_WANT_READ:
				commSetSelect(fd, COMM_SELECT_READ, private_fwdNegotiateSSL, s, 0);
				return;
			case SSL_ERROR_WANT_WRITE:
				commSetSelect(fd, COMM_SELECT_WRITE, private_fwdNegotiateSSL,s, 0);
				return;
			default:
				debug(153, 1) ("private_fwdNegotiateSSL: Error negotiating SSL connection on FD %d: %s (%d/%d/%d)\n", fd, ERR_error_string(ERR_get_error(), NULL), ssl_error, ret, errno);
			cbdataFree(s);
			comm_close(fd);
			return ;
		}
	}
	
	pconnPush(fd,s->ip_addr,s->port,NULL,NULL,0);
	commSetTimeout(fd,s->pconn_timeout,NULL,NULL);
	debug(153, 4) ("private_fwdNegotiateSSL: succeed negotiating SSL connection on FD:%d \n",fd);
	return;
}
Ejemplo n.º 2
0
static void private_openIdleConnDone(int fd,int status, void* data)
{
	server* s = data;
	debug(151,3)("mod_server_persist_connections-->private_openIdleConnDone: ip_addr == %s \t port == %d, fd == %d\n",s->ip_addr, s->port,fd);
	if(fd>0)
	{
		if(s->proto == PROTO_HTTPS)
		{
			private_fwdInitiateSSL(fd,s); 
		}else{
			pconnPush(fd,s->ip_addr,s->port,NULL,NULL,0);
	        commSetTimeout(fd,s->pconn_timeout,NULL,NULL);
			cbdataFree(s); //Does fwdConnectIdleTimeOut will free!!!
		}
	}
}
Ejemplo n.º 3
0
/*
 * icapRespModKeepAliveOrClose
 *
 * Called when we are done reading from the ICAP server.
 * Either close the connection or keep it open for a future
 * transaction.
 */
static void
icapRespModKeepAliveOrClose(IcapStateData * icap)
{
    int fd = icap->icap_fd;
    if (fd < 0)
	return;
    if (!icap->flags.keep_alive) {
	debug(81, 3) ("%s:%d keep_alive not set, closing\n", __FILE__,
	    __LINE__);
	comm_close(fd);
	return;
    }
    debug(81, 3) ("%s:%d FD %d looks good, keeping alive\n", __FILE__, __LINE__,
	fd);
    commSetDefer(fd, NULL, NULL);
    commSetTimeout(fd, -1, NULL, NULL);
    commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
    comm_remove_close_handler(fd, icapStateFree, icap);
    pconnPush(fd, icap->current_service->hostname, icap->current_service->port);
    icap->icap_fd = -1;
    icapStateFree(-1, icap);
}