On Wednesday 16 March 2005 16:33, Tiago Jorge wrote:
i've added some debug and you are right. the error is on the call of the socket function. the constructor is right. here is the code of the constructor:
FailureDetector::FailureDetector(int new_eid, int new_sleep_time, vector<int> *new_group, //pthread_mutex_t *new_group_lock){
l4lock_t *new_group_lock){ eid = new_eid; sleep_time = new_sleep_time; group = new_group; group_lock = new_group_lock; trueFlag_fd = 0x1; stop_flag = false; sock_fd=0;
LOG("Before start thread\n"); fdect = l4thread_create(helper_failure_detector, NULL, L4THREAD_CREATE_ASYNC); LOG("After start thread\n"); }
it passes ok...
then he executes this code:
How is FailureDetector::failureDetector() called?
void FailureDetector::failureDetector(){ heartbeat hb; bool recvfrom_error = false; map<int,heartbeat> received; map<int,heartbeat> pre_suspicious;
/*initialization procedures*/ //pthread_mutex_init(&lock_suspected, NULL); //pthread_mutex_init(&lock_stop, NULL); LOG("before initialize_comm_fd()\n"); initialize_comm_fd();
[...]
and the initialize_comm_fd bugs out. here is the code:
void FailureDetector::initialize_comm_fd(){ int flags=0, s=0;
LOG("before socket\n"); /* Create socket from which to send */ if ((sock_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { <--- ERROR!!!!! LOG("socket error\n"); } LOG("after socket\n"); [...]
Frank