[Sslproxy-users] SSL proxy server could not restart immediately after killing
Brought to you by:
szilu
From: Daobang W. <dao...@pr...> - 2007-12-19 00:48:39
|
Hi All I have a problem about SSL proxy server rebooting. SSL proxy server could not be restarted after killing if there is active https session exists, and I find the root cause: On Linux OS, if there is a socket binding a port, after the socket is closed or the program exit normally, the port could not be release at once, if I restart the SSL proxy server it will report binding error, the address could not be used at once. I add the method "setsockopt" to resolve this issue after the socket created and before binding the port in method "server_init", please see the follows, the blue line is added by us. server_socket=socket(AF_INET, SOCK_STREAM, 0); if (server_socket<0) { perror("socket()"); exit(1); } server.sin_family=AF_INET; inet_pton(AF_INET, addr, &ipaddr); server.sin_addr.s_addr=ipaddr; // server.sin_addr.s_addr=htons(INADDR_ANY); server.sin_port=htons(port); z = setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &so_reuseaddr, sizeof so_reuseaddr); if (z==-1) { perror("setsockopt(SO_REUSEADDR)"); } if (bind(server_socket, (struct sockaddr *)&server, sizeof(server)) < 0) { perror("bind()"); exit(1); } And then, I could restart the SSL proxy server. Why the bug is not fixed, and is there any risk of adding the above change? Or would you like to give another way to resolve this issue? Thank you very much. Best wishes, Daobang. |