- sprintf(transid, "%x_%d", tmp->mid, newtid);
- //Browse through each oid in machine group
- for(i = 0; i < tmp->index; i++) {
- headeraddr = (objheader_t *) chashSearch(record->lookupTable, tmp->obj[i]);
- //check if object modified in cache
- if((headeraddr->status >> 1) == 1){
- //Keep track of oids that have been modified
- oidmod[nummod] = headeraddr->oid;
- nummod++;
- tot_bytes_mod += (sizeof(objheader_t) + classsize[headeraddr->type]); //Keeps track of total bytes of modified object
- } else {
- //Keep track of oids that are read
- oidread[numread] = headeraddr->oid;
- //create <oid,version> tuples in temporary buffer
- memcpy(tmpbuffer+offset, &headeraddr->oid, sizeof(unsigned int));
- offset += sizeof(unsigned int);
- memcpy(tmpbuffer+offset, &headeraddr->version, sizeof(short));
- offset += sizeof(short);
- numread++;
- }
- }
- //Copy each field of the packet into buffer
- bzero((char *)buffer,sizeof(buffer));
- offset = 0;
- buffer[offset] = TRANS_REQUEST;
- offset = offset + 1;
- memcpy(buffer+offset, transid, sizeof(char) * TID_LEN);
- offset += (sizeof(char) * TID_LEN);
- memcpy(buffer+offset, &pilecount, sizeof(int));
- offset += sizeof(int);
- memcpy(buffer+offset, &numread, sizeof(short));
- offset += sizeof(short);
- memcpy(buffer+offset, &nummod, sizeof(short));
- offset += sizeof(short);
- memcpy(buffer+offset, &tot_bytes_mod, sizeof(unsigned int));
- offset += sizeof(unsigned int);
- memcpy(buffer+offset, listmid, sizeof(unsigned int) * pilecount);
- offset += (sizeof(unsigned int) * pilecount);
- memcpy(buffer+offset, tmpbuffer, sizeof(char) * RECEIVE_BUFFER_SIZE);
- offset += (sizeof(char) * RECEIVE_BUFFER_SIZE);
- //send objects for all objects modified
- for( i= 0; i< nummod; i++) {
- headeraddr = (objheader_t *) chashSearch(record->lookupTable, oidmod[i]);
- memcpy(buffer+offset, headeraddr, sizeof(objheader_t) + classsize[headeraddr->type]);
- offset += sizeof(objheader_t) + classsize[headeraddr->type];