Browse code

*** empty log message ***

Daniel-Constantin Mierla authored on 05/08/2002 16:33:22
Showing 3 changed files
... ...
@@ -184,7 +184,7 @@ static int mod_init(void)
184 184
 		return -1;
185 185
 	}
186 186
 	
187
-	if((jab_wlist_init_ssock(jwl, "gorn.fokus.gmd.de", 5060) < 0) || (jab_wlist_init_contact(jwl, contact) < 0))
187
+	if(jab_wlist_init_contact(jwl, contact) < 0)
188 188
 	{
189 189
 		DBG("JABBER: mod_init: error workers list properties\n");
190 190
 		return -1;
... ...
@@ -240,9 +240,9 @@ static int child_init(int rank)
240 240
 	{
241 241
 		for(i=0;i<nrw;i++)
242 242
 			close(pipes[i][0]);
243
-		for(i = 0; i < nrw; i++)
244
-			pkg_free(pipes[i]);
245
-		pkg_free(pipes);
243
+		//for(i = 0; i < nrw; i++)
244
+		//	pkg_free(pipes[i]);
245
+		//pkg_free(pipes);
246 246
 	}
247 247
 	return 0;
248 248
 }
... ...
@@ -412,9 +412,8 @@ void destroy(void)
412 412
 			db_close(db_con[i]);
413 413
 		shm_free(db_con);
414 414
 	}
415
-	if(jwl->ssock > 0)
416
-		close(jwl->ssock);
417 415
 			
418 416
 	jab_wlist_free(jwl);
419 417
 	DBG("JABBER: Unloaded\n");
420 418
 }
419
+
... ...
@@ -98,7 +98,6 @@ jab_wlist jab_wlist_init(int **pipes, int size, int max)
98 98
 		return NULL;
99 99
 	jwl->len = size;
100 100
 	jwl->maxj = max;
101
-	jwl->ssock = -1;
102 101
 	jwl->contact_h = NULL;
103 102
 	//jwl->semid = init_mutex(SEM_KEY);
104 103
 	if((jwl->sems = create_semaphores(size)) == NULL)
... ...
@@ -150,36 +149,6 @@ int jab_wlist_init_contact(jab_wlist jwl, char *ch)
150 149
 	return 0;
151 150
 }
152 151
 
153
-/**
154
- * initialize the socket that will be used to send SIP messages
155
- * - jwl : pointer to the workers list
156
- * - sserv : name of the SIP server where SIP messages are sent
157
- * - sport : port of the SIP server where SIP messages are sent
158
- * #return : 0 on success or <0 on error
159
- */
160
-int jab_wlist_init_ssock(jab_wlist jwl, char *sserv, int sport)
161
-{
162
-	struct hostent *hp;
163
-
164
-	if(jwl == NULL)
165
-		return -1;
166
-	if ((jwl->ssock = socket( PF_INET, SOCK_DGRAM, 0 )) < 0)
167
-    {
168
-    	DBG("JABBER: jab_wlist_init_ssock: Problem creating socket\n");
169
-    	return -2;
170
-    }
171
-	
172
-	jwl->sserver.sin_family = AF_INET;
173
-	if ((hp = gethostbyname(sserv))==0)
174
-	{
175
-    	DBG("JABBER: jab_wlist_init_ssock: Invalid or unknown host\n");
176
-	    return -3;
177
-  	}
178
-	memcpy( &jwl->sserver.sin_addr.s_addr, hp->h_addr, hp->h_length);
179
-	jwl->sserver.sin_port = htons(sport);
180
-
181
-	return 0;
182
-}
183 152
 
184 153
 /**
185 154
  * set the p.id's of the workers
... ...
@@ -206,6 +175,7 @@ int jab_wlist_set_pids(jab_wlist jwl, int *pids, int size)
206 175
 void jab_wlist_free(jab_wlist jwl)
207 176
 {
208 177
 	int i;
178
+	DBG("JABBER: jab_wlist_free : freeing 'jab_wlist' memory ...\n");
209 179
 	if(jwl == NULL)
210 180
 		return;
211 181
 	
... ...
@@ -598,59 +568,42 @@ int worker_process(jab_wlist jwl, char* jaddress, int jport, int pipe, int size,
598 568
 								write(1, "JABBER: JMSG START ----------\n", 30);
599 569
 								write(1, recv_buff, n);
600 570
 								write(1, "\nJABBER: JMSG END ----------\n", 29);
601
-								if(jwl->ssock > 0)
571
+								recv_buff[n] = 0;
572
+								if(strstr(recv_buff, "<message ") != NULL)
602 573
 								{
603
-									recv_buff[n] = 0;
604
-									if(strstr(recv_buff, "<message ") != NULL)
574
+									if(j2s_parse_jmsgx(recv_buff, n, &tjmsg) >=0)
605 575
 									{
606
-										if(j2s_parse_jmsgx(recv_buff, n, &tjmsg) >=0)
576
+										DBG("JABBER: worker_process:%d: sending as SIP ...\n", _pid);
577
+										buff[0] = 0;
578
+										if(tjmsg.error.len > 0)
607 579
 										{
608
-											DBG("JABBER: worker_process:%d: sending as SIP ...\n", _pid);
609
-											buff[0] = 0;
610
-											if(tjmsg.error.len > 0)
611
-											{
612
-												strcpy(buff, "{Error: ");
613
-												if(tjmsg.errcode.len > 0)
614
-												{
615
-													strncat(buff, tjmsg.errcode.s, tjmsg.errcode.len);
616
-													strncat(buff, " - ", 3);
617
-												}
618
-												strncat(buff, tjmsg.error.s, tjmsg.error.len);
619
-												strcat(buff, ". The following message was NOT sent}: ");
620
-											}
621
-											strncat(buff, tjmsg.body.s, tjmsg.body.len);
622
-											if((n= xml_unescape(buff, strlen(buff), tbuff, 1024)) > 0)
580
+											strcpy(buff, "{Error: ");
581
+											if(tjmsg.errcode.len > 0)
623 582
 											{
624
-												tstr.s = tbuff;
625
-												tstr.len = n;
626
-												// if(jab_send_sip_msg(jcp->ojc[i]->id, &tjmsg.from, &tjmsg.from, &tstr) < 0)
627
-												if(jab_send_sip_msg(jcp->ojc[i]->id, &tjmsg.from, jwl->contact_h, &tstr) < 0)
628
-													DBG("JABBER: worker_process:%d: ERROR SIP MESSAGE was not sent ...\n", _pid);
629
-												else
630
-													DBG("JABBER: worker_process:%d: SIP MESSAGE was sent ...\n", _pid);
631
-/***************************											
632
-												tbuff[n] = 0;
633
-												strncpy(buff, tjmsg.from.s, tjmsg.from.len);
634
-												buff[tjmsg.from.len] = 0;
635
-												if(jwl->contact_h == NULL)
636
-													sprintf(send_buff, SIP_MESSAGE, jcp->ojc[i]->id->len, jcp->ojc[i]->id->s, buff, jcp->ojc[i]->id->len, jcp->ojc[i]->id->s, "", buff, _pid, cseq++, n, tbuff);
637
-												else
638
-													sprintf(send_buff, SIP_MESSAGE, jcp->ojc[i]->id->len, jcp->ojc[i]->id->s, buff, jcp->ojc[i]->id->len, jcp->ojc[i]->id->s, jwl->contact_h, buff, _pid, cseq++, n, tbuff);
639
-
640
-												write(1, "JABBER: SIPMSG START ----------\n", 32);
641
-												write(1, send_buff, strlen(send_buff));
642
-												write(1, "\nJABBER: SIPMSG END ----------\n", 31);
643
-												n = sendto(jwl->ssock, send_buff, strlen(send_buff) ,0, (struct sockaddr*) &jwl->sserver, sizeof(jwl->sserver));
644
-*******/										
583
+												strncat(buff, tjmsg.errcode.s, tjmsg.errcode.len);
584
+												strncat(buff, " - ", 3);
645 585
 											}
586
+											strncat(buff, tjmsg.error.s, tjmsg.error.len);
587
+											strcat(buff, ". The following message was NOT sent}: ");
588
+										}
589
+										strncat(buff, tjmsg.body.s, tjmsg.body.len);
590
+										if((n= xml_unescape(buff, strlen(buff), tbuff, 1024)) > 0)
591
+										{
592
+											tstr.s = tbuff;
593
+											tstr.len = n;
594
+											// if(jab_send_sip_msg(jcp->ojc[i]->id, &tjmsg.from, &tjmsg.from, &tstr) < 0)
595
+											if(jab_send_sip_msg(jcp->ojc[i]->id, &tjmsg.from, jwl->contact_h, &tstr) < 0)
596
+												DBG("JABBER: worker_process:%d: ERROR SIP MESSAGE was not sent ...\n", _pid);
646 597
 											else
647
-											{
648
-												DBG("JABBER: worker_process:%d: ERROR sending as sip: output buffer too small ...\n", _pid);
649
-											}
598
+												DBG("JABBER: worker_process:%d: SIP MESSAGE was sent ...\n", _pid);
650 599
 										}
651 600
 										else
652
-											DBG("JABBER: worker_process:%d: ERROR parsing jabber message ...\n", _pid);
601
+										{
602
+											DBG("JABBER: worker_process:%d: ERROR sending as sip: output buffer too small ...\n", _pid);
603
+										}
653 604
 									}
605
+									else
606
+										DBG("JABBER: worker_process:%d: ERROR parsing jabber message ...\n", _pid);
654 607
 								}
655 608
 							}
656 609
 							else
... ...
@@ -33,7 +33,6 @@ typedef struct _jab_wlist
33 33
 {
34 34
 	int len;   			// length of the list
35 35
 	int maxj;			// maximum jobs / worker
36
-	int ssock;			// sip response socket
37 36
 	struct sockaddr_in sserver;  // sip server address
38 37
 	str *contact_h;	// contact header
39 38
     //int semid;          // semaphore for mutual access to the list
... ...
@@ -84,7 +83,6 @@ typedef struct _jc_pool
84 83
 /**********   LOOK AT IMPLEMENTATION OF FUNCTIONS FOR DESCRIPTION    ***/
85 84
 
86 85
 jab_wlist jab_wlist_init(int **, int, int);
87
-int jab_wlist_init_ssock(jab_wlist, char *, int);
88 86
 int jab_wlist_init_contact(jab_wlist, char *);
89 87
 int jab_wlist_set_pids(jab_wlist, int *, int);
90 88
 int jab_wlist_get(jab_wlist, str *, str **);