+ /* Send TRANS_PREFETCH control message */
+ control = TRANS_PREFETCH;
+ if(send(sd, &control, sizeof(char), MSG_NOSIGNAL) < sizeof(char)) {
+ perror("Error in sending prefetch control\n");
+ return;
+ }
+
+ /* Send Oids and offsets in pairs */
+ tmp = mcpilenode->objpiles;
+ while(tmp != NULL) {
+ off = offset = 0;
+ len = sizeof(int) + sizeof(unsigned int) + ((tmp->numoffset) * sizeof(short));
+ char oidnoffset[len];
+ memcpy(oidnoffset, &len, sizeof(int));
+ off = sizeof(int);
+ memcpy(oidnoffset + off, &tmp->oid, sizeof(unsigned int));
+ off += sizeof(unsigned int);
+ for(i = 0; i < numoffsets; i++) {
+ offset = off + (i * sizeof(short));
+ memcpy(oidnoffset + offset, tmp->offset, sizeof(short));
+ }
+ if (send(sd, &oidnoffset, sizeof(oidnoffset),MSG_NOSIGNAL) < sizeof(oidnoffset)) {
+ perror("Error sending fixed bytes for thread\n");
+ return;
+ }
+ tmp = tmp->next;
+ }
+
+ endpair = -1;
+ if (send(sd, &endpair, sizeof(int), MSG_NOSIGNAL) < sizeof(int)) {
+ perror("Error sending fixed bytes for thread\n");
+ return;
+ }
+
+ /* Get Response from the remote machine */
+ getPrefetchResponse();
+
+// close(sd);
+}
+
+void getPrefetchResponse() {
+ int i;
+
+ /* Lock the Prefetch Cache look up table*/
+ pthread_mutex_lock(&pflookup.lock);
+
+ /*TODO For each object found add to Prefetch Cache */
+
+ /* Broadcast signal on prefetch cache condition variable */
+ pthread_cond_broadcast(&pflookup.qcond);
+
+ /* Unlock the Prefetch Cache look up table*/
+ pthread_mutex_unlock(&pflookup.lock);
+
+
+
+
+