rem: if (safe_write( p, tr->req->s, tr->req->len)!=-1) { lock_release( p->mutex); tr->out_peer = p; tr->req = 0;  add_to_timer_list( &(tr->timeout) , tr_timeout_timer , get_ticks()+TR_TIMEOUT_TIMEOUT );  return 1; } lock_release( p->mutex);  remove_cell_from_htable( p->trans_table, &(tr->linker) ); return -1;
add: foo = tr->req; tr->out_peer = p; tr->req = 0;  add_to_timer_list( &(tr->timeout) , tr_timeout_timer , get_ticks()+TR_TIMEOUT_TIMEOUT );  safe_write( p, foo->s, foo->len); return 1;
context: int send_req_to_peer(struct trans *tr , struct peer *p){	unsigned int ete;	str s;	lock_get( p->mutex );	if ( p->state!=PEER_CONN && p->state!=PEER_WAIT_DWA) {		LOG(L_INFO,"ERROR:send_req_to_peer: peer is not connected\n");		lock_release( p->mutex);		return -1;	}	/* peer available for sending */	DBG("peer \"%.*s\" available for sending\n",p->aaa_identity.len,			p->aaa_identity.s);	/* get a new end-to-end ID for computing the hash code */	if (tr->in_peer) {		/* this is forwarding*/		ete = ((unsigned int*)tr->req->s)[4];	}else {		/* sending local req */		ete = p->endtoendID++;		((unsigned int*)tr->req->s)[4] = ete;	}	s.s = (char*)&ete;	s.len = END_TO_END_IDENTIFIER_SIZE;	tr->linker.hash_code = hash( &s , p->trans_table->hash_size );	/* insert into trans hash table */	add_cell_to_htable( p->trans_table, &(tr->linker) );	/* the hash label is used as hop-by-hop ID */	((unsigned int*)tr->req->s)[3] = tr->linker.label;	/* send it */	if (safe_write( p, tr->req->s, tr->req->len)!=-1) {		lock_release( p->mutex);		tr->out_peer = p;		tr->req = 0;		/* start the timeout timer */		add_to_timer_list( &(tr->timeout) , tr_timeout_timer ,			get_ticks()+TR_TIMEOUT_TIMEOUT );		/* success */		return 1;	}	lock_release( p->mutex);	/* write failed*/	remove_cell_from_htable( p->trans_table, &(tr->linker) );	return -1;}