diff --git a/net/common/session.c b/net/common/session.c index 6caedda..e3e1a2e 100644 --- a/net/common/session.c +++ b/net/common/session.c @@ -81,7 +81,6 @@ static int load_rsakey(CcnetSession *session) return 0; } -static void listen_on_localhost (CcnetSession *session); static void listen_on_pipe (CcnetSession *session); static void save_pubinfo (CcnetSession *session); @@ -99,12 +98,12 @@ ccnet_session_load_config (CcnetSession *session, int ret = 0; char *config_file = NULL, *config_dir = NULL, *central_config_dir = NULL; char *id = NULL, *name = NULL, *port_str = NULL, - *lport_str = NULL, *un_path = NULL, + *un_path = NULL, *user_name = NULL; #ifdef CCNET_SERVER char *service_url; #endif - int port, local_port = 0; + int port; unsigned char sha1[20]; GKeyFile *key_file; @@ -147,7 +146,6 @@ ccnet_session_load_config (CcnetSession *session, #endif port_str = ccnet_key_file_get_string (key_file, "Network", "PORT"); - lport_str = ccnet_key_file_get_string (key_file, "Client", "PORT"); un_path = ccnet_key_file_get_string (key_file, "Client", "UNIX_SOCKET"); if (port_str == NULL) { @@ -166,9 +164,6 @@ ccnet_session_load_config (CcnetSession *session, goto onerror; } - if (lport_str) - local_port = atoi (lport_str); - memcpy (session->base.id, id, 40); session->base.id[40] = '\0'; session->base.name = g_strdup(name); @@ -181,7 +176,6 @@ ccnet_session_load_config (CcnetSession *session, session->config_dir = config_dir; session->central_config_dir = central_config_dir; session->un_path = un_path; - session->local_port = local_port; session->keyf = key_file; load_rsakey(session); @@ -193,7 +187,6 @@ onerror: g_free (name); g_free (user_name); g_free (port_str); - g_free (lport_str); #ifdef CCNET_SERVER g_free (service_url); #endif @@ -252,15 +245,7 @@ ccnet_session_prepare (CcnetSession *session, if (test_config) { return 0; } else { - /* Open localhost, if failed, then the program will exists. This is used - * to prevent two instance of ccnet on the same port. - */ -#ifdef WIN32 - listen_on_localhost (session); -#else listen_on_pipe (session); -#endif - /* refresh pubinfo on every startup */ save_pubinfo (session); } @@ -329,8 +314,6 @@ ccnet_session_save_config (CcnetSession *session) g_key_file_set_integer (session->keyf, "Network", "PORT", session->base.public_port); - g_key_file_set_integer (session->keyf, "Client", "PORT", session->local_port); - str = g_key_file_to_data (session->keyf, NULL, &error); if (error) { ccnet_warning ("Can't save unauth peer info: %s\n", @@ -407,22 +390,6 @@ static void accept_local_client (evutil_socket_t fd, short event, void *vsession g_object_unref (peer); } -static void listen_on_localhost (CcnetSession *session) -{ - int sockfd; - - if ( (sockfd = ccnet_net_bind_v4 ("127.0.0.1", &session->local_port)) < 0) { - printf ("listen on localhost failed\n"); - exit (1); - } - ccnet_message ("Listen on 127.0.0.1 %d\n", session->local_port); - - listen (sockfd, 5); - event_set (&session->local_event, sockfd, EV_READ | EV_PERSIST, - accept_local_client, session); - event_add (&session->local_event, NULL); -} - #ifndef WIN32 static void listen_on_pipe (CcnetSession *session) diff --git a/net/common/session.h b/net/common/session.h index 6238ef1..09ecd6c 100644 --- a/net/common/session.h +++ b/net/common/session.h @@ -86,7 +86,6 @@ struct CcnetSession unsigned int saving_pub : 1; unsigned int encrypt_channel : 1; - int local_port; char *un_path; struct event local_event; struct event local_pipe_event; diff --git a/tools/ccnet-init.c b/tools/ccnet-init.c index 4748962..f67fba1 100644 --- a/tools/ccnet-init.c +++ b/tools/ccnet-init.c @@ -241,17 +241,6 @@ make_configure_file (const char *config_file) } fprintf (fp, "\n"); - fprintf (fp, "[Client]\n"); - - /* Use differnet ports for ccnet-daemon and ccnet-server */ - if (port_str != NULL) { - /* ccnet-server */ - fprintf (fp, "PORT = 13418\n"); - } else { - /* ccnet-daemon */ - fprintf (fp, "PORT = 13419\n"); - } - fclose (fp); fprintf (stdout, "done\n");