-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
each send is considered a transaction #498
Changes from all commits
90a3797
4c5157a
ba6f316
5c84d1e
4ffa9a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- Add: support for MongoDB replica sets (using the new -rplSet CLI parameter) (Issue #493) | ||
- Fix: each send is now considered a separate transaction (Issue #478) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,46 +148,55 @@ std::string sendHttpSocket | |
|
||
++callNo; | ||
|
||
LM_TRANSACTION_START("to", ip.c_str(), port, resource.c_str()); | ||
|
||
// Preconditions check | ||
if (port == 0) | ||
{ | ||
LM_E(("Runtime Error (port is ZERO)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
if (ip.empty()) | ||
{ | ||
LM_E(("Runtime Error (ip is empty)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
if (verb.empty()) | ||
{ | ||
LM_E(("Runtime Error (verb is empty)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
if (resource.empty()) | ||
{ | ||
LM_E(("Runtime Error (resource is empty)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
if ((content_type.empty()) && (!content.empty())) | ||
{ | ||
LM_E(("Runtime Error (Content-Type is empty but there is actual content)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
if ((!content_type.empty()) && (content.empty())) | ||
{ | ||
LM_E(("Runtime Error (Content-Type non-empty but there is no content)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
if ((curl = curl_easy_init()) == NULL) | ||
{ | ||
LM_E(("Runtime Error (could not init libcurl)")); | ||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
|
@@ -298,6 +307,7 @@ std::string sendHttpSocket | |
free(httpResponse->memory); | ||
delete httpResponse; | ||
|
||
LM_TRANSACTION_END(); | ||
return "error"; | ||
} | ||
|
||
|
@@ -334,7 +344,7 @@ std::string sendHttpSocket | |
else | ||
{ | ||
// The Response is here | ||
LM_I(("Notification Successfully Sent")); | ||
LM_I(("Notification Successfully Sent to %s", url.c_str())); | ||
result.assign(httpResponse->memory, httpResponse->size); | ||
} | ||
|
||
|
@@ -345,6 +355,7 @@ std::string sendHttpSocket | |
free(httpResponse->memory); | ||
delete httpResponse; | ||
|
||
LM_TRANSACTION_END(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we mantain the old function, the LM_TRANSACTION_START()/LM_TRANSACTION_END() should be also adjusted in the #else/#endif block below this lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, just in case ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4c5157a |
||
return result; | ||
} | ||
|
||
|
@@ -361,6 +372,8 @@ int socketHttpConnect(const std::string& host, unsigned short port) | |
struct addrinfo* peer; | ||
char port_str[10]; | ||
|
||
LM_TRANSACTION_START("to", ip.c_str(), port, resource.c_str()); | ||
|
||
memset(&hints, 0, sizeof(struct addrinfo)); | ||
hints.ai_socktype = SOCK_STREAM; | ||
hints.ai_protocol = 0; | ||
|
@@ -386,12 +399,14 @@ int socketHttpConnect(const std::string& host, unsigned short port) | |
if (getaddrinfo(host.c_str(), port_str, &hints, &peer) != 0) | ||
{ | ||
LM_W(("Notification failure for %s:%d (getaddrinfo: %s)", host.c_str(), port, strerror(errno))); | ||
LM_TRANSACTION_END(); | ||
return -1; | ||
} | ||
|
||
if ((fd = socket(peer->ai_family, peer->ai_socktype, peer->ai_protocol)) == -1) | ||
{ | ||
LM_W(("Notification failure for %s:%d (socket: %s)", host.c_str(), port, strerror(errno))); | ||
LM_TRANSACTION_END(); | ||
return -1; | ||
} | ||
|
||
|
@@ -400,10 +415,12 @@ int socketHttpConnect(const std::string& host, unsigned short port) | |
freeaddrinfo(peer); | ||
close(fd); | ||
LM_W(("Notification failure for %s:%d (connect: %s)", host.c_str(), port, strerror(errno))); | ||
LM_TRANSACTION_END(); | ||
return -1; | ||
} | ||
|
||
freeaddrinfo(peer); | ||
LM_TRANSACTION_END(); | ||
return fd; | ||
} | ||
|
||
|
@@ -641,7 +658,7 @@ std::string sendHttpSocket | |
else | ||
{ | ||
memcpy(response, buffer, nb); | ||
LM_I(("Notification Successfully Sent")); | ||
LM_I(("Notification Successfully Sent to %s:%d%s", ip.c_str(), port, resource.c_str())); | ||
LM_T(LmtClientInputPayload, ("Received from HTTP server:\n%s", response)); | ||
} | ||
|
||
|
@@ -651,7 +668,7 @@ std::string sendHttpSocket | |
else | ||
{ | ||
LM_T(LmtClientInputPayload, ("not waiting for response")); | ||
LM_I(("Notification Successfully Sent")); | ||
LM_I(("Notification Successfully Sent to %s:%d%s", ip.c_str(), port, resource.c_str())); | ||
result = ""; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -626,7 +626,7 @@ static int connectionTreat | |
// | ||
// Transaction starts here | ||
// | ||
LM_TRANSACTION_START(ip, port, url); // Incoming REST request starts | ||
LM_TRANSACTION_START("from", ip, port, url); // Incoming REST request starts | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not part of this PR but just to check... where is the LM_TRANSACTION_END() corresponding to this start? (A URL to the line/file in gitub.com will be welcomed ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NTC |
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHANGES_NEXT_RELEASE entry missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4c5157a