/* Print out incoming variable adds or deletes. */ int dp_PASCAL print_cb(dptab_t *dptab, dptab_table_t *table, playerHdl_t src, playerHdl_t dest, char *subkey, int subkeylen, void *buf, size_t sent, size_t total, int seconds_left, void *context, dp_result_t err) { dptab_table_t *sessions = (dptab_table_t *)context; printf("print_cb: src h:%x, dest h:%x, table %s, subkey %s, err %d\n", src, dest, key2a(table->key, table->keylen), key2a2(subkey, subkeylen), err); return TRUE; }
/*------------------------------------------------------------------------- This is called by the dptab_handlePacket when a new variable arrives or an old one is deleted. Note the time of the callback in the result block. -------------------------------------------------------------------------*/ int dp_PASCAL table_cb( dptab_t *dptab, /* table owner */ dptab_table_t *table, /* table */ playerHdl_t src, /* */ playerHdl_t dest, /* */ char *subkey, /* key of variable */ int subkeylen, /* number of bytes in subkey */ void *buf, /* pointer to variable */ size_t sent, size_t total, int seconds_left, void *context, /* whatever we gave it */ dp_result_t err) /* operation completed upon variable */ { clock_t now = eclock(); printf("Node %d: table_cb: type:%d src h:%x dest h:%x table:%s key:%s\n", results.thisHost, err, src, dest, key2a(table->key, table->keylen), key2a2(subkey, subkeylen)); if (err == dp_RES_CREATED || err == dp_RES_CHANGED) { /*printf("table_cb: CREATED/CHANGED: src h:%x dest h:%x table:%s key:%s\n", src, dest, key2a(table->key, table->keylen), key2a2(subkey, subkeylen));*/ if ((dest == PLAYER_ME) && (sent == total)) { /* Got a variable */ switch (subkey[0]) { case SUBKEY_SINGLE_SMALL: if(table->key[0] == 2) { results.gotSingleSmallTime = now; results.singleSmallTime = ((float)now - results.sentSingleSmallTime) / ECLOCKS_PER_SEC; /* Move this statement to right after last measurement taken */ writeReport(logFile, &results); } break; case SUBKEY_SINGLE_LARGE: results.gotSingleLargeTime = now; break; case SUBKEY_MULTIPLE_SMALL: results.gotMultipleSmallTime = now; break; default: ; } printf("Node %d: Got variable from h:%x; table %s, subkey %s; len %d\n", results.thisHost, src, key2a(table->key, table->keylen), key2a2(subkey, subkeylen), total); } } else if (err == dp_RES_CLOSED) { /*printf("table_cb: Deleted: src h:%x dest h:%x\n", src, dest);*/ if (dest == PLAYER_ME) { switch (subkey[0]) { case SUBKEY_SINGLE_SMALL: results.gotDeleteTime = now; results.deleteTime = ((float)now - results.sentDeleteTime) / ECLOCKS_PER_SEC; break; default: ; } printf("Node %d: Got delete variable from h:%x; table %s, subkey %s\n", results.thisHost, src, key2a(table->key, table->keylen), key2a2(subkey, subkeylen)); } } (void) dptab; (void) buf; (void) seconds_left; (void) context; return TRUE; }