/** Worker function for thread that manages the control connection of FTP session. */ void* control_thread_proc(void* info) { struct control_thread_info* cti = (struct control_thread_info*)info; // set appropriate signal mask for this thread sigset_t sigs; sigemptyset (&sigs); sigaddset (&sigs, SIGINT); sigaddset (&sigs, SIGPIPE); pthread_sigmask (SIG_BLOCK, &sigs, NULL); if (send_welcome_message(cti->session) == -1) cti->session->terminated = 1; control_thread_loop (cti); char buf[MAX_PATH]; snprintf (buf, MAX_PATH, "Client `%s` disconnected.", cti->session->ip_address); log_event (cti->session->server, buf); // end the control connection int sfd = cti->session->control_socket; shutdown (sfd, SHUT_RDWR); TEMP_FAILURE_RETRY(close(sfd)); // end the data connection if any int dfd = cti->session->data_socket; if (!(dfd < 0)) { shutdown (dfd, SHUT_RDWR); TEMP_FAILURE_RETRY(close(dfd)); } free (cti); return 0; }
void handle_hello_message(zeroconf_msg& message) { if (strcmp((char *)message.source(),my_ip)) { debug_->debug("receive hello(%u)",radio_->id()); radio_->send( Os::Radio::BROADCAST_ADDRESS, sizeof(zeroconf_msg), (Os::Radio::block_data_t *)&message);//forward the message send_welcome_message((char *)message.source());//and send welcome message } }