salt(NULL),
table(NULL),
listeningPort(-1),
- localServerThread(NULL),
doEnd(false),
timer(TimingSingleton_getInstance()),
getslot(new Array<char>("getslot", 7)),
salt(NULL),
table(_table),
listeningPort(_listeningPort),
- localServerThread(NULL),
doEnd(false),
timer(TimingSingleton_getInstance()) {
if (listeningPort > 0) {
}
response[offset] = 0;
int ver1 = 0, ver2 = 0, respcode = 0;
- sscanf(response, "HTTP-%d.%d %d", &ver1, &ver2, &respcode);
+ sscanf(response, "HTTP/%d.%d %d", &ver1, &ver2, &respcode);
+ printf("Response code %d\n", respcode);
return respcode;
}
void CloudComm::closeCloud() {
doEnd = true;
- if (localServerThread != NULL) {
+ if (listeningPort > 0) {
if (pthread_join(localServerThread, NULL) != 0)
throw new Error("Local Server thread join issue...");
}
if (!isDead) {
isDead = true;
// Make all the parts of this transaction dead
- for (int32_t partNumber = 0; partNumber < parts->size(); partNumber++) {
+ for (uint32_t partNumber = 0; partNumber < parts->size(); partNumber++) {
CommitPart *part = parts->get(partNumber);
if (parts != NULL)
part->setDead();
void Commit::decodeCommitData() {
// Calculate the size of the data section
int dataSize = 0;
- for (int i = 0; i < parts->size(); i++) {
+ for (uint i = 0; i < parts->size(); i++) {
CommitPart *tp = parts->get(i);
if (tp != NULL)
dataSize += tp->getDataSize();
int currentPosition = 0;
// Stitch all the data sections together
- for (int i = 0; i < parts->size(); i++) {
+ for (uint i = 0; i < parts->size(); i++) {
CommitPart *tp = parts->get(i);
if (tp != NULL) {
System_arraycopy(tp->getData(), 0, combinedData, currentPosition, tp->getDataSize());
directories: ${OBJ_DIR}
test: bin/lib_iotcloud.so
- g++ Test.C -L./bin/ -l_iotcloud -o bin/Test
+ g++ Test.C -L./bin/ -l_iotcloud -lpthread -lbsd -o bin/Test
${OBJ_DIR}:
${MKDIR_P} ${OBJ_DIR}
#include "SecureRandom.h"
#include <stdlib.h>
+#include <bsd/stdlib.h>
SecureRandom::SecureRandom() {
}
}
void SlotBuffer::resize(int newsize) {
- if (newsize == (array->length() - 1))
+ if ((uint32_t)newsize == (array->length() - 1))
return;
Array<Slot *> *newarray = new Array<Slot *>(newsize + 1);
int index = tail;
for (int i = 0; i < currsize; i++) {
newarray->set(i, array->get(index));
- if ((++index) == array->length())
+ if (((uint32_t)++index) == array->length())
index = 0;
}
array = newarray;
void SlotBuffer::incrementHead() {
head++;
- if (head >= array->length())
+ if (((uint32_t)head) >= array->length())
head = 0;
}
void SlotBuffer::incrementTail() {
tail++;
- if (tail >= array->length())
+ if (((uint32_t)tail) >= array->length())
tail = 0;
}
return NULL;
}
- if (index >= array->length()) {
+ if (((uint32_t)index) >= array->length()) {
if (head >= tail) {
return NULL;
}
- index -= array->length();
+ index -= (int32_t) array->length();
}
- if (index >= array->length()) {
+ if (((uint32_t)index) >= array->length()) {
return NULL;
}
Slot *SlotIndexer::getSlot(int64_t seqnum) {
if (seqnum >= firstslotseqnum) {
int32_t offset = (int32_t) (seqnum - firstslotseqnum);
- if (offset >= updates->length())
+ if (((uint32_t)offset) >= updates->length())
throw new Error("Invalid Slot Sequence Number Reference");
else
return updates->get(offset);
Hashset<int64_t> *arbitratorTriedAndFailed = new Hashset<int64_t>();
uint size = pendingTransactionQueue->size();
uint oldindex = 0;
- for (int iter = 0; iter < size; iter++) {
+ for (uint iter = 0; iter < size; iter++) {
Transaction *transaction = pendingTransactionQueue->get(iter);
pendingTransactionQueue->set(oldindex++, pendingTransactionQueue->get(iter));
s->addEntry(rm);
} else {
int64_t prev_seqn = -1;
- int i = 0;
+ uint i = 0;
/* Go through list of missing messages */
for (; i < rejectedSlotVector->size(); i++) {
int64_t curr_seqn = rejectedSlotVector->get(i);
bool hadCommit = (lastRound->getCommit() == NULL);
bool gotNewCommit = false;
- int numberToDelete = 1;
+ uint numberToDelete = 1;
while (numberToDelete < pendingSendArbitrationRounds->size()) {
ArbitrationRound *round = pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size() - numberToDelete - 1);
if (numberToDelete == pendingSendArbitrationRounds->size()) {
pendingSendArbitrationRounds->clear();
} else {
- for (int i = 0; i < numberToDelete; i++) {
+ for (uint i = 0; i < numberToDelete; i++) {
pendingSendArbitrationRounds->removeIndex(pendingSendArbitrationRounds->size() - 1);
}
}
}
// Go through each new commit one by one
- for (int i = 0; i < commitSequenceNumbers->size(); i++) {
+ for (uint i = 0; i < commitSequenceNumbers->size(); i++) {
int64_t commitSequenceNumber = commitSequenceNumbers->get(i);
Commit *commit = commitForClientTable->get(commitSequenceNumber);
oldestTransactionSequenceNumberSpeculatedOn = transactionSequenceNumbersSorted->get(0);
// Find where to start arbitration from
- int startIndex = 0;
+ uint startIndex = 0;
for (; startIndex < transactionSequenceNumbersSorted->size(); startIndex++)
if (transactionSequenceNumbersSorted->get(startIndex) == lastTransactionSequenceNumberSpeculatedOn)
Hashset<int64_t> *incompleteTransactionArbitrator = new Hashset<int64_t>();
bool didSkip = true;
- for (int i = startIndex; i < transactionSequenceNumbersSorted->size(); i++) {
+ for (uint i = startIndex; i < transactionSequenceNumbersSorted->size(); i++) {
int64_t transactionSequenceNumber = transactionSequenceNumbersSorted->get(i);
Transaction *transaction = liveTransactionBySequenceNumberTable->get(transactionSequenceNumber);
}
// Find where to start arbitration from
- int startIndex = 0;
+ uint startIndex = 0;
for (; startIndex < pendingTransactionQueue->size(); startIndex++)
if (pendingTransactionQueue->get(startIndex) == firstPendingTransaction)
return;
}
- for (int i = startIndex; i < pendingTransactionQueue->size(); i++) {
+ for (uint i = startIndex; i < pendingTransactionQueue->size(); i++) {
Transaction *transaction = pendingTransactionQueue->get(i);
lastPendingTransactionSpeculatedOn = transaction;
* Check if the HMAC chain is not violated
*/
void Table::checkHMACChain(SlotIndexer *indexer, Array<Slot *> *newSlots) {
- for (int i = 0; i < newSlots->length(); i++) {
+ for (uint i = 0; i < newSlots->length(); i++) {
Slot *currSlot = newSlots->get(i);
Slot *prevSlot = indexer->getSlot(currSlot->getSequenceNumber() - 1);
if (prevSlot != NULL &&
void Transaction::setSequenceNumber(int64_t _sequenceNumber) {
sequenceNumber = _sequenceNumber;
- for (int32_t i = 0; i < parts->size(); i++) {
+ for (uint32_t i = 0; i < parts->size(); i++) {
TransactionPart *tp = parts->get(i);
if (tp != NULL)
tp->setSequenceNumber(sequenceNumber);
// Set dead
isDead = true;
// Make all the parts of this transaction dead
- for (int32_t partNumber = 0; partNumber < parts->size(); partNumber++) {
+ for (uint32_t partNumber = 0; partNumber < parts->size(); partNumber++) {
TransactionPart *part = parts->get(partNumber);
if (part != NULL)
part->setDead();
void Transaction::decodeTransactionData() {
// Calculate the size of the data section
int dataSize = 0;
- for (int i = 0; i < parts->size(); i++) {
+ for (uint i = 0; i < parts->size(); i++) {
TransactionPart *tp = parts->get(i);
dataSize += tp->getDataSize();
}
int currentPosition = 0;
// Stitch all the data sections together
- for (int i = 0; i < parts->size(); i++) {
+ for (uint i = 0; i < parts->size(); i++) {
TransactionPart *tp = parts->get(i);
System_arraycopy(tp->getData(), 0, combinedData, currentPosition, tp->getDataSize());
currentPosition += tp->getDataSize();
int64_t arbitratorId;
int64_t machineId;
Pair<int64_t, int64_t> transactionId;
- int nextPartToSend;
+ uint32_t nextPartToSend;
bool flddidSendAPartToServer;
TransactionStatus *transactionStatus;
bool hadServerFailure;
};
template<typename type>
-void System_arraycopy(Array<type> *src, int32_t srcPos, Array<type> *dst, int32_t dstPos, int32_t len) {
+void System_arraycopy(Array<type> *src, uint32_t srcPos, Array<type> *dst, uint32_t dstPos, uint32_t len) {
if (srcPos + len > src->length() ||
dstPos + len > dst->length())
ASSERT(0);