[Swift-commit] cog r3463
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Sun Sep 9 03:35:03 CDT 2012
------------------------------------------------------------------------
r3463 | hategan | 2012-09-09 03:32:52 -0500 (Sun, 09 Sep 2012) | 1 line
added some logging messages and removed ConnecError in favor of CoasterError
------------------------------------------------------------------------
Index: modules/provider-coaster-c-client/src/CoasterClient.cpp
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClient.cpp (revision 3462)
+++ modules/provider-coaster-c-client/src/CoasterClient.cpp (working copy)
@@ -7,6 +7,7 @@
#include "CoasterClient.h"
#include "JobSubmitCommand.h"
+#include "CoasterError.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -17,14 +18,6 @@
#include "Logger.h"
-ConnectionError::ConnectionError(string msg) {
- message = msg.c_str();
-}
-
-const char* ConnectionError::what() const throw() {
- return message;
-}
-
CoasterClient::CoasterClient(string URLp, CoasterLoop& ploop) {
URL = URLp;
sockFD = 0;
@@ -37,6 +30,8 @@
return;
}
+ LogInfo << "Starting client " << getHostName() << endl;
+
struct addrinfo* addrInfo;
struct addrinfo* it;
@@ -51,7 +46,10 @@
continue;
}
+ LogDebug << "Trying " << inet_ntoa(((sockaddr_in*) (it->ai_addr))->sin_addr) << endl;
+
if (connect(sockFD, it->ai_addr, it->ai_addrlen) == 0) {
+ LogDebug << "Connected" << endl;
break;
}
@@ -66,10 +64,10 @@
if (sockFD == -1) {
// none succeeded
if (error != NULL) {
- throw ConnectionError("Failed to connect to " + URL + ": " + error);
+ throw CoasterError("Failed to connect to %s: %s", URL.c_str(), error);
}
else {
- throw ConnectionError("Failed to connect to " + URL);
+ throw CoasterError("Failed to connect to %s", URL.c_str());
}
}
@@ -78,6 +76,8 @@
channel->start();
loop->addChannel(channel);
+ LogInfo << "Done" << endl;
+
started = true;
}
@@ -86,12 +86,16 @@
return;
}
+ LogInfo << "Stopping client " << getHostName() << endl;
+
channel->shutdown();
loop->removeChannel(channel);
close(sockFD);
delete channel;
+ LogInfo << "Done" << endl;
+
started = false;
}
@@ -186,7 +190,7 @@
int result = getaddrinfo(hostName, sPort, &hints, &info);
if (result != 0) {
- throw ConnectionError(string("Host name lookup failure: ") + gai_strerror(result));
+ throw CoasterError("Host name lookup failure: %s", gai_strerror(result));
}
free(sPort);
Index: modules/provider-coaster-c-client/src/CoasterClient.h
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClient.h (revision 3462)
+++ modules/provider-coaster-c-client/src/CoasterClient.h (working copy)
@@ -27,15 +27,6 @@
class CoasterLoop;
class CoasterChannel;
-class ConnectionError: public exception {
- private:
- const char* message;
- public:
- ConnectionError(string msg);
-
- virtual const char* what() const throw();
-};
-
class CoasterClient: public CommandCallback {
private:
Lock lock;
More information about the Swift-commit
mailing list