Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions JSONDB/JSONDB.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,16 @@ JsonBox::Object JSONDB::query(JsonBox::Object request, unsigned retries)
}

// connect to database
if (!connect(dbPath)) {
response["code"] = JsonBox::Value(500);
response["data"] = JsonBox::Value("db connect failed");
return response;
int retry_count = 0;
while(!connect(dbPath)) {
usleep(100); // sleep 0.1 second
retry_count++;

if (retry_count > MAX_DB_CONNECT_ATTEMPTS) {
response["code"] = JsonBox::Value(503);
response["data"] = JsonBox::Value("db connect failed");
return response;
}
}

// abstract sip_buddies and dialdata_tables into a single logical endpoint
Expand Down
1 change: 1 addition & 0 deletions JSONDB/JSONDB.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <string>
#include <vector>

#define MAX_DB_CONNECT_ATTEMPTS 10

class JSONDB {

Expand Down