]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/liborte/ORTEAppSendThread.c
version 0.2.2 (mac, solaris patch)
[orte.git] / orte / liborte / ORTEAppSendThread.c
index dddc446f037d7ac15b4237a612b1d7163eb331a3..5ce3b388b4a7c00fe21af1a5b64735c2ecafe2c9 100644 (file)
@@ -36,7 +36,7 @@ void ORTESendData(ORTEDomain *d,ObjectEntryAID *objectEntryAID,Boolean meta) {
       des.sin_family=AF_INET; 
       des.sin_addr.s_addr = htonl(appParams->unicastIPAddressList[i]);
       if (meta) {
-        des.sin_port = htons((u_int16_t)appParams->metatrafficUnicastPort); 
+        des.sin_port = htons((uint16_t)appParams->metatrafficUnicastPort); 
         sock_sendto (
             &d->taskSend.sock,
             d->mbSend.cdrStream.buffer,
@@ -44,13 +44,21 @@ void ORTESendData(ORTEDomain *d,ObjectEntryAID *objectEntryAID,Boolean meta) {
             &des,
             sizeof(des)); 
       } else {
-        des.sin_port = htons((u_int16_t)appParams->userdataUnicastPort); 
-        sock_sendto (
-            &d->taskSend.sock,
-            d->mbSend.cdrStreamDirect->buffer,
-            d->mbSend.cdrStreamDirect->length,
-            &des,
-            sizeof(des)); 
+        des.sin_port = htons((uint16_t)appParams->userdataUnicastPort); 
+        if (d->mbSend.cdrStreamDirect)
+          sock_sendto (
+              &d->taskSend.sock,
+              d->mbSend.cdrStreamDirect->buffer,
+              d->mbSend.cdrStreamDirect->length,
+              &des,
+              sizeof(des)); 
+        else
+          sock_sendto (
+              &d->taskSend.sock,
+              d->mbSend.cdrStream.buffer,
+              d->mbSend.cdrStream.length,
+              &des,
+              sizeof(des)); 
       }
     }
   }
@@ -85,9 +93,14 @@ void ORTEAppSendThread(ORTEDomain *d) {
     if (s<0) s=ms=0;
     debug(24,4) ("ORTEAppSendThread: sleeping for %lis %lims\n",s,ms);
     if (!((wtime.tv_sec==0) && (wtime.tv_nsec==0))) {
-      pthread_mutex_timedlock(
-          &d->objectEntry.htimSendMutex,
-          &wtime);
+      pthread_mutex_lock(&d->objectEntry.htimSendMutex);
+      if (d->objectEntry.htimSendCondValue==0) {
+        pthread_cond_timedwait(&d->objectEntry.htimSendCond,
+                              &d->objectEntry.htimSendMutex,
+                              &wtime);
+      }
+      d->objectEntry.htimSendCondValue=0;
+      pthread_mutex_unlock(&d->objectEntry.htimSendMutex);
     }
     debug(24,7) ("ORTEAppSendThread: fired\n");
     actTime=getActualNtpTime();