#include "ByteBuffer.h"
#include "aes.h"
#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/tcp.h>
+//#include <sys/socket.h>
+//#include <arpa/inet.h>
+//#include <netinet/tcp.h>
#include <unistd.h>
-#include <netdb.h>
+//#include <netdb.h>
/**
* Empty Constructor needed for child class.
timer(TimingSingleton_getInstance()),
getslot(new Array<char>("getslot", 7)),
putslot(new Array<char>("putslot", 7)) {
- if (listeningPort > 0) {
+ /* if (listeningPort > 0) {
pthread_create(&localServerThread, NULL, threadWrapper, this);
- }
+ }*/
}
CloudComm::~CloudComm() {
* Generates Key from password.
*/
AESKey *CloudComm::initKey() {
- try {
- AESKey *key = new AESKey(password->internalBytes(),
- salt,
- 65536,
- 128);
- return key;
- } catch (Exception *e) {
- throw new Error("Failed generating key.");
- }
+ AESKey *key = new AESKey(password->internalBytes(),
+ salt,
+ 65536,
+ 128);
+ return key;
}
/**
if (password == NULL) {
return;
}
- try {
- key = initKey();
- delete password;
- password = NULL;// drop password
- mac = new Mac();
- mac->init(key);
- } catch (Exception *e) {
- throw new Error("Failed To Initialize Ciphers");
- }
+ key = initKey();
+ delete password;
+ password = NULL;// drop password
+ mac = new Mac();
+ mac->init(key);
}
/*
return urlstr;
}
-void loopWrite(int fd, char *array, int bytestowrite) {
+void loopWrite(TCPClient client, char *array, int bytestowrite) {
int byteswritten = 0;
while (bytestowrite) {
- int bytes = write(fd, &array[byteswritten], bytestowrite);
+ int bytes = client.write(&array[byteswritten], bytestowrite);
if (bytes >= 0) {
byteswritten += bytes;
bytestowrite -= bytes;
}
}
-void loopRead(int fd, char *array, int bytestoread) {
+void loopRead(TCPClient client, char *array, int bytestoread) {
int bytesread = 0;
while (bytestoread) {
- int bytes = read(fd, &array[bytesread], bytestoread);
+ int bytes = client.read(&array[bytesread], bytestoread);
if (bytes >= 0) {
bytesread += bytes;
bytestoread -= bytes;
memcpy(&message[endpost + post + url->length() + hostlen - i], host, i - 7);
sprintf(&message[endpost + post + url->length() + hostlen - 7], "\r\n");
- /* create the socket */
- int sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if (sockfd < 0) {printf("ERROR opening socket\n"); exit(-1);}
-
- /* lookup the ip address */
- struct hostent *server = gethostbyname(host);
- free(host);
-
- if (server == NULL) {printf("ERROR, no such host"); exit(-1);}
- /* fill in the structure */
- struct sockaddr_in serv_addr;
+ WebConnection wc;
+ wc.numBytes = -1;
- memset(&serv_addr,0,sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(80);
- memcpy(&serv_addr.sin_addr.s_addr,server->h_addr,server->h_length);
-
- /* connect the socket */
- if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) {
- printf("ERROR connecting");
- exit(-1);
+ if (!wc.client.connect(host, 80)) {
+ myerror("ERROR connecting\n");
}
-
+ free(host);
+
/* send the request */
int total = strlen(message);
loopWrite(sockfd, message, total);
free(message);
- return (WebConnection) {sockfd, -1};
+ return wc;
}
-int createSocket(IoTString *name, int port) {
+TCPClient createSocket(IoTString *name, int port) {
char *host = (char *) malloc(name->length() + 1);
memcpy(host, name->internalBytes()->internalArray(), name->length());
host[name->length()] = 0;
if (sockfd < 0) {printf("ERROR opening socket\n"); exit(-1);}
/* lookup the ip address */
- struct hostent *server = gethostbyname(host);
- free(host);
-
- if (server == NULL) {printf("ERROR, no such host"); exit(-1);}
-
- /* fill in the structure */
- struct sockaddr_in serv_addr;
-
- memset(&serv_addr,0,sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(port);
- memcpy(&serv_addr.sin_addr.s_addr,server->h_addr,server->h_length);
-
- /* connect the socket */
- if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) {
- printf("ERROR connecting");
- exit(-1);
+ TCPClient client;
+ if (!client.connect(host, port)) {
+ myerror("ERROR connecting\n");
}
- return sockfd;
+ free(host);
+ return client;
}
-int createSocket(int port) {
+TCPServer createSocket(int port) {
int fd;
struct sockaddr_in sin;
+ TCPServer server = TCPServer(port);
+ server.begin();
- bzero(&sin, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_port = htons(port);
- sin.sin_addr.s_addr = htonl(INADDR_ANY);
- fd = socket(AF_INET, SOCK_STREAM, 0);
- int n = 1;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&n, sizeof (n)) < 0) {
- close(fd);
- printf("Create Socket Error\n");
- exit(-1);
- }
- if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- close(fd);
- exit(-1);
- }
- if (listen(fd, 5) < 0) {
- close(fd);
- exit(-1);
- }
- return fd;
+ return server;
}
-int acceptSocket(int socket) {
- struct sockaddr_in sin;
- unsigned int sinlen = sizeof(sin);
- int newfd = accept(socket, (struct sockaddr *)&sin, &sinlen);
- int flag = 1;
- setsockopt(newfd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(flag));
- if (newfd < 0) {
- printf("Accept Error\n");
- exit(-1);
- }
- return newfd;
-}
void writeSocketData(int fd, Array<char> *data) {
loopWrite(fd, data->internalArray(), data->length());
}
WebConnection wc = {-1, -1};
- try {
+ // try {
Array<char> *saltTmp = new Array<char>(CloudComm_SALT_SIZE);
random->nextBytes(saltTmp);
int responsecode = getResponseCode(&wc);
if (responsecode != HttpURLConnection_HTTP_OK) {
- throw new Error("Invalid response");
+ //throw new Error("Invalid response");
+ myerror("Invalid response\n");
}
close(wc.fd);
timer->endTime();
salt = saltTmp;
- } catch (Exception *e) {
+ /* } catch (Exception *e) {
timer->endTime();
throw new ServerException("Failed setting salt", ServerException_TypeConnectTimeout);
- }
+ }*/
}
bool CloudComm::getSalt() {
WebConnection wc = {-1, -1};
IoTString *urlstr = NULL;
- try {
+ // try {
char *buffer = (char *) malloc(baseurl->length() + 100);
memcpy(buffer, baseurl->internalBytes()->internalArray(), baseurl->length());
int offset = baseurl->length();
offset += sprintf(&buffer[offset], "?req=getsalt");
urlstr = new IoTString(buffer);
free(buffer);
- } catch (Exception *e) {
+ /* } catch (Exception *e) {
throw new Error("getSlot failed");
- }
- try {
+ }*/
+ // try {
timer->startTime();
wc = openURL(urlstr);
delete urlstr;
urlstr = NULL;
closeURLReq(&wc);
timer->endTime();
- } catch (SocketTimeoutException *e) {
+ /* } catch (SocketTimeoutException *e) {
if (urlstr)
delete urlstr;
timer->endTime();
if (urlstr)
delete urlstr;
throw new Error("getSlot failed");
- }
+ }*/
- try {
+ // try {
timer->startTime();
int responsecode = getResponseCode(&wc);
readHeaders(&wc);
if (responsecode != HttpURLConnection_HTTP_OK) {
- throw new Error("Invalid response");
+ //throw new Error("Invalid response");
+ myerror("Invalid response\n");
}
if (wc.numBytes == 0) {
timer->endTime();
salt = tmp;
timer->endTime();
return true;
- } catch (SocketTimeoutException *e) {
+ /* } catch (SocketTimeoutException *e) {
timer->endTime();
throw new ServerException("getSalt failed", ServerException_TypeInputTimeout);
} catch (Exception *e) {
throw new Error("getSlot failed");
- }
+ }*/
}
Array<char> *CloudComm::createIV(int64_t machineId, int64_t localSequenceNumber) {
}
Array<char> *CloudComm::encryptSlotAndPrependIV(Array<char> *rawData, Array<char> *ivBytes) {
- try {
+ // try {
Array<char> *encryptedBytes = AESEncrypt(ivBytes, key, rawData);
Array<char> *chars = new Array<char>(encryptedBytes->length() + CloudComm_IV_SIZE);
System_arraycopy(ivBytes, 0, chars, 0, ivBytes->length());
System_arraycopy(encryptedBytes, 0, chars, CloudComm_IV_SIZE, encryptedBytes->length());
delete encryptedBytes;
return chars;
- } catch (Exception *e) {
+ /* } catch (Exception *e) {
throw new Error("Failed To Encrypt");
- }
+ }*/
}
Array<char> *CloudComm::stripIVAndDecryptSlot(Array<char> *rawData) {
- try {
+ // try {
Array<char> *ivBytes = new Array<char>(CloudComm_IV_SIZE);
Array<char> *encryptedBytes = new Array<char>(rawData->length() - CloudComm_IV_SIZE);
System_arraycopy(rawData, 0, ivBytes, 0, CloudComm_IV_SIZE);
delete encryptedBytes;
delete ivBytes;
return data;
- } catch (Exception *e) {
+ /* } catch (Exception *e) {
throw new Error("Failed To Decrypt");
- }
+ }*/
}
/*
*/
Array<Slot *> *CloudComm::putSlot(Slot *slot, int max) {
WebConnection wc = {-1, -1};
- try {
+ // try {
if (salt == NULL) {
if (!getSalt()) {
- throw new ServerException("putSlot failed", ServerException_TypeSalt);
+ // throw new ServerException("putSlot failed", ServerException_TypeSalt);
+ myerror("putSlot failed\n");
}
initCrypt();
}
writeURLDataAndClose(&wc, chars);
delete chars;
timer->endTime();
- } catch (ServerException *e) {
+ /* } catch (ServerException *e) {
timer->endTime();
throw e;
} catch (SocketTimeoutException *e) {
throw new ServerException("putSlot failed", ServerException_TypeConnectTimeout);
} catch (Exception *e) {
throw new Error("putSlot failed");
- }
+ }*/
Array<char> *resptype = NULL;
- try {
+ // try {
int respcode = getResponseCode(&wc);
readHeaders(&wc);
timer->startTime();
} else {
delete resptype;
close(wc.fd);
- throw new Error("Bad response to putslot");
+ //throw new Error("Bad response to putslot");
+ myerror("Bad response to putslot\n");
}
- } catch (SocketTimeoutException *e) {
+ /* } catch (SocketTimeoutException *e) {
if (resptype != NULL)
delete resptype;
timer->endTime();
if (resptype != NULL)
delete resptype;
throw new Error("putSlot failed");
- }
+ }*/
}
/**
*/
Array<Slot *> *CloudComm::getSlots(int64_t sequencenumber) {
WebConnection wc = {-1, -1};
- try {
+ // try {
if (salt == NULL) {
if (!getSalt()) {
- throw new ServerException("getSlots failed", ServerException_TypeSalt);
+ //throw new ServerException("getSlots failed", ServerException_TypeSalt);
+ myerror("getSlots failed\n");
}
initCrypt();
}
delete url;
closeURLReq(&wc);
timer->endTime();
- } catch (SocketTimeoutException *e) {
+ /* } catch (SocketTimeoutException *e) {
timer->endTime();
throw new ServerException("getSlots failed", ServerException_TypeConnectTimeout);
} catch (ServerException *e) {
throw e;
} catch (Exception *e) {
throw new Error("getSlots failed");
- }
+ }*/
- try {
+ // try {
timer->startTime();
int responsecode = getResponseCode(&wc);
readHeaders(&wc);
readURLData(&wc, resptype);
timer->endTime();
if (!resptype->equals(getslot))
- throw new Error("Bad Response: ");
+ // throw new Error("Bad Response: ");
+ myerror("Bad Response: \n");
delete resptype;
Array<Slot *> *tmp = processSlots(&wc);
close(wc.fd);
return tmp;
- } catch (SocketTimeoutException *e) {
+ /* } catch (SocketTimeoutException *e) {
timer->endTime();
close(wc.fd);
throw new ServerException("getSlots failed", ServerException_TypeInputTimeout);
} catch (Exception *e) {
throw new Error("getSlots failed");
- }
+ }*/
}
/**
Array<char> *CloudComm::sendLocalData(Array<char> *sendData, int64_t localSequenceNumber, IoTString *host, int port) {
if (salt == NULL)
return NULL;
- try {
+ // try {
printf("Passing Locally\n");
mac->update(sendData, 0, sendData->length());
Array<char> *genmac = mac->doFinal();
System_arraycopy(returnData, returnData->length() - realmac->length(), recmac, 0, realmac->length());
if (!recmac->equals(realmac))
- throw new Error("Local Error: Invalid HMAC! Potential Attack!");
+ // throw new Error("Local Error: Invalid HMAC! Potential Attack!");
+ myerror("Local Error: Invalid HMAC! Potential Attack!\n");
Array<char> *returnData2 = new Array<char>(lengthOfReturnData - recmac->length());
System_arraycopy(returnData, 0, returnData2, 0, returnData2->length());
return returnData2;
- } catch (Exception *e) {
+ /* } catch (Exception *e) {
printf("Exception\n");
- }
+ }*/
return NULL;
}
void CloudComm::localServerWorkerFunction() {
- int inputSocket = -1;
-
+ /* int inputSocket = -1;
+
try {
// Local server socket
inputSocket = createSocket(listeningPort);
} catch (Exception *e) {
throw new Error("Local server setup failure...");
}
-
+
while (!doEnd) {
try {
// Accept incoming socket
int socket = acceptSocket(inputSocket);
-
+
// Get the encrypted data from the server
int dataSize = readSocketInt(socket);
Array<char> *readData = new Array<char>(dataSize);
readSocketData(socket, readData);
timer->endTime();
-
+
// Decrypt the data
readData = stripIVAndDecryptSlot(readData);
mac->update(readData, 0, readData->length() - CloudComm_HMAC_SIZE);
System_arraycopy(readData, readData->length() - recmac->length(), recmac, 0, recmac->length());
if (!recmac->equals(genmac))
- throw new Error("Local Error: Invalid HMAC! Potential Attack!");
+ // throw new Error("Local Error: Invalid HMAC! Potential Attack!");
+ error("Local Error: Invalid HMAC! Potential Attack!\n");
Array<char> *returnData = new Array<char>(readData->length() - recmac->length());
System_arraycopy(readData, 0, returnData, 0, returnData->length());
} catch (Exception *e) {
}
}
-
+
if (inputSocket != -1) {
try {
close(inputSocket);
} catch (Exception *e) {
throw new Error("Local server close failure...");
}
- }
+ }*/
}
void CloudComm::closeCloud() {
doEnd = true;
- if (listeningPort > 0) {
+ /* if (listeningPort > 0) {
if (pthread_join(localServerThread, NULL) != 0)
throw new Error("Local Server thread join issue...");
- }
+ }*/
}
}
delete pendingSendArbitrationEntriesToDelete;
{
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(transactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(transactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
delete trit->currVal();
} else {
delete s;
delete array;
- throw new Error("Error on initialization");
+ //throw new Error("Error on initialization");
+ myerror("Error on initialization\n");
}
}
KeyValue *kv = committedKeyValueTable->get(key);
if (!arbitratorTable->contains(key)) {
- throw new Error("Key not Found.");
+ // throw new Error("Key not Found.");
+ myerror("Key not found!\n");
}
// Make sure new key value pair matches the current arbitrator
if (!pendingTransactionBuilder->checkArbitrator(arbitratorTable->get(key))) {
// TODO: Maybe not throw en error
- throw new Error("Not all Key Values Match Arbitrator.");
+ //throw new Error("Not all Key Values Match Arbitrator.");
+ myerror("Not all key values match arbitrator\n");
}
if (kv != NULL) {
IoTString *Table::getSpeculativeAtomic(IoTString *key) {
if (!arbitratorTable->contains(key)) {
- throw new Error("Key not Found.");
+ //throw new Error("Key not Found.");
+ myerror("Key not found\n");
}
// Make sure new key value pair matches the current arbitrator
if (!pendingTransactionBuilder->checkArbitrator(arbitratorTable->get(key))) {
// TODO: Maybe not throw en error
- throw new Error("Not all Key Values Match Arbitrator.");
+ //throw new Error("Not all Key Values Match Arbitrator.");
+ myerror("Not all Key Values Match Arbitrator.\n");
}
KeyValue *kv = pendingTransactionSpeculatedKeyValueTable->get(key);
}
bool Table::update() {
- try {
+ //try {
Array<Slot *> *newSlots = cloud->getSlots(sequenceNumber + 1);
validateAndUpdate(newSlots, false);
delete newSlots;
sendToServer(NULL);
updateLiveTransactionsAndStatus();
return true;
- } catch (Exception *e) {
+ /* } catch (Exception *e) {
SetIterator<int64_t, Pair<IoTString *, int32_t> *> *kit = getKeyIterator(localCommunicationTable);
while (kit->hasNext()) {
int64_t m = kit->next();
updateFromLocal(m);
}
delete kit;
- }
+ }*/
return false;
}
void Table::put(IoTString *key, IoTString *value) {
// Make sure it is a valid key
if (!arbitratorTable->contains(key)) {
- throw new Error("Key not Found.");
+ //throw new Error("Key not Found.");
+ myerror("Key not Found.\n");
}
// Make sure new key value pair matches the current arbitrator
if (!pendingTransactionBuilder->checkArbitrator(arbitratorTable->get(key))) {
// TODO: Maybe not throw en error
- throw new Error("Not all Key Values Match Arbitrator.");
+ //throw new Error("Not all Key Values Match Arbitrator.");
+ myerror("Not all Key Values Match Arbitrator.\n");
}
// Add the key value to this transaction
pendingTransactionBuilder = new PendingTransaction(localMachineId);
- try {
+ // try {
sendToServer(NULL);
- } catch (ServerException *e) {
+ /* } catch (ServerException *e) {
Hashset<int64_t> *arbitratorTriedAndFailed = new Hashset<int64_t>();
uint size = pendingTransactionQueue->size();
}
}
pendingTransactionQueue->setSize(oldindex);
- }
+ }*/
updateLiveStateFromLocal();
}
void Table::processTransactionList(bool handlePartial) {
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(lastTransactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *)getKeyIterator(lastTransactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetServerFailure();
}
}
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(lastTransactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *)getKeyIterator(lastTransactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetServerFailure();
processTransactionList(true);
} else {
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(lastTransactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(lastTransactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetServerFailure();
void Table::clearSentParts() {
// Clear the sent data since we are trying again
pendingSendArbitrationEntriesToDelete->clear();
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(transactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(transactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
delete trit->currVal();
newKey = handlePartialSend(newKey);
}
- try {
+ // try {
// While we have stuff that needs inserting into the block chain
while ((pendingTransactionQueue->size() > 0) || (pendingSendArbitrationRounds->size() > 0) || (newKey != NULL)) {
if (hadPartialSendToServer) {
- throw new Error("Should Be error free");
+ // throw new Error("Should Be error free");
+ myerror("Should Be error free\n");
}
// If there is a new key with same name then end
if (needsResize) {
// Reset which transaction to send
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(transactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(transactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetNextPartToSend();
processTransactionList(false);
} else {
// Reset which transaction to send
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(transactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(transactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetNextPartToSend();
}
delete newSlots;
}
- } catch (ServerException *e) {
+ /* } catch (ServerException *e) {
if (e->getType() != ServerException_TypeInputTimeout) {
// Nothing was able to be sent to the server so just clear these data structures
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(transactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(transactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetNextPartToSend();
hadPartialSendToServer = true;
// Nothing was able to be sent to the server so just clear these data structures
- SetIterator<Transaction *, Vector<int> *> *trit = getKeyIterator(transactionPartsSent);
+ SetIterator<Transaction *, Vector<int> *> *trit = (SetIterator<Transaction *, Vector<int> *> *) getKeyIterator(transactionPartsSent);
while (trit->hasNext()) {
Transaction *transaction = trit->next();
transaction->resetNextPartToSend();
clearSentParts();
throw e;
- }
+ }*/
return newKey == NULL;
}
return true;
} else {
if ((*array)->length() == 0) {
- throw new Error("Server Error: Did not send any slots");
+ // throw new Error("Server Error: Did not send any slots");
+ myerror("Server Error: Did not send any slots\n");
}
if (hadPartialSendToServer) {
// client has seen
int64_t firstSeqNum = newSlots->get(0)->getSequenceNumber();
if (firstSeqNum <= sequenceNumber) {
- throw new Error("Server Error: Sent older slots!");
+ // throw new Error("Server Error: Sent older slots!");
+ myerror("Server Error: Sent older slots!\n");
}
// Create an object that can access both new slots and slots in our
// hiding slots
if (!machineSet->isEmpty()) {
delete machineSet;
- throw new Error("Missing record for machines: ");
+ //throw new Error("Missing record for machines: ");
+ myerror("Missing record for machines: \n");
}
}
delete machineSet;
*/
void Table::checkNumSlots(int numberOfSlots) {
if (numberOfSlots != expectedsize) {
- throw new Error("Server Error: Server did not send all slots-> Expected: ");
+ //throw new Error("Server Error: Server did not send all slots-> Expected: ");
+ myerror("Server Error: Server did not send all slots-> Expected: \n");
}
}
processEntry((TableStatus *)entry, slot->getSequenceNumber());
break;
default:
- throw new Error("Unrecognized type: ");
+ //throw new Error("Unrecognized type: ");
+ myerror("Unrecognized type: \n");
}
}
}
// a rejected slot
int64_t slotMachineId = slot->getMachineID();
if (isequal != (slotMachineId == machineId)) {
- throw new Error("Server Error: Trying to insert rejected message for slot ");
+ //throw new Error("Server Error: Trying to insert rejected message for slot ");
+ myerror("Server Error: Trying to insert rejected message for slot\n");
}
}
}
} else if (livenessType == TypeSlot) {
((Slot *)liveness)->setDead();
} else {
- throw new Error("Unrecognized type");
+ //throw new Error("Unrecognized type");
+ myerror("Unrecognized type\n");
}
}
// Get the old last message for this device
} else if (lastEntryType == TypeSlot) {
((Slot *)lastEntry)->setDead();
} else {
- throw new Error("Unrecognized type");
+ //throw new Error("Unrecognized type");
+ myerror("Unrecognized type\n");
}
}
// Make sure the server is not playing any games
if (hadPartialSendToServer) {
// We were not making any updates and we had a machine mismatch
if (lastMessageSeqNum > seqNum && !acceptUpdatesToLocal) {
- throw new Error("Server Error: Mismatch on local machine sequence number, needed at least: ");
+ //throw new Error("Server Error: Mismatch on local machine sequence number, needed at least: ");
+ myerror("Server Error: Mismatch on local machine sequence number, needed at least: \n");
}
} else {
// We were not making any updates and we had a machine mismatch
if (lastMessageSeqNum != seqNum && !acceptUpdatesToLocal) {
- throw new Error("Server Error: Mismatch on local machine sequence number, needed: ");
+ //throw new Error("Server Error: Mismatch on local machine sequence number, needed: ");
+ myerror("Server Error: Mismatch on local machine sequence number, needed: \n");
}
}
} else {
if (lastMessageSeqNum > seqNum) {
- throw new Error("Server Error: Rollback on remote machine sequence number");
+ //throw new Error("Server Error: Rollback on remote machine sequence number");
+ myerror("Server Error: Rollback on remote machine sequence number\n");
}
}
}
Slot *prevSlot = indexer->getSlot(currSlot->getSequenceNumber() - 1);
if (prevSlot != NULL &&
!prevSlot->getHMAC()->equals(currSlot->getPrevHMAC()))
- throw new Error("Server Error: Invalid HMAC Chain");
+ // throw new Error("Server Error: Invalid HMAC Chain");
+ myerror("Server Error: Invalid HMAC Chain\n");
}
}