This commit is contained in:
Vitaly Takmazov 2012-03-21 15:40:37 +04:00
commit c47ff469f5
5 changed files with 54 additions and 11 deletions

View file

@ -1658,7 +1658,21 @@ int main(int argc, char **argv) {
}
else {
log4cxx::helpers::Properties p;
log4cxx::helpers::FileInputStream *istream = new log4cxx::helpers::FileInputStream(KEYFILE_STRING("logging", "backend_config"));
log4cxx::helpers::FileInputStream *istream = NULL;
try {
istream = new log4cxx::helpers::FileInputStream(KEYFILE_STRING("logging", "backend_config"));
}
catch(log4cxx::helpers::IOException &ex) {
std::cerr << "Can't create FileInputStream logger instance: " << ex.what() << "\n";
}
catch (...) {
std::cerr << "Can't create FileInputStream logger instance\n";
}
if (!istream) {
return 1;
}
p.load(istream);
LogString pid, jid;
log4cxx::helpers::Transcoder::decode(stringOf(getpid()), pid);

View file

@ -38,7 +38,13 @@ class SpectrumNetworkPlugin;
#define GET_RESPONSE_DATA(RESP, DATA) ((RESP.find(std::string(DATA) + " ") != std::string::npos) ? RESP.substr(RESP.find(DATA) + strlen(DATA) + 1) : "");
#define GET_PROPERTY(VAR, OBJ, WHICH, PROP) std::string VAR = sk->send_command(std::string("GET ") + OBJ + " " + WHICH + " " + PROP); \
VAR = GET_RESPONSE_DATA(VAR, PROP);
try {\
VAR = GET_RESPONSE_DATA(VAR, PROP);\
}\
catch (std::out_of_range& oor) {\
VAR="";\
}
SpectrumNetworkPlugin *np;
@ -547,7 +553,12 @@ bool Skype::loadSkypeBuddies() {
name = GET_RESPONSE_DATA(name, "DISPLAYNAME");
std::string users = send_command("GET GROUP " + data[1] + " USERS");
users = GET_RESPONSE_DATA(users, "USERS");
try {
users = GET_RESPONSE_DATA(users, "USERS");
}
catch (std::out_of_range& oor) {
continue;
}
boost::split(data, users, boost::is_any_of(","));
BOOST_FOREACH(std::string u, data) {
group_map[u] = grp;

View file

@ -2,10 +2,13 @@ cmake_minimum_required(VERSION 2.6)
FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../include/transport/*.h)
set(EXTRA_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../../src/memoryusage.cpp)
set(EXTRA_SOURCES ${EXTRA_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
if (NOT WIN32)
ADD_LIBRARY(transport-plugin SHARED ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ../../src/memoryusage.cpp ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
ADD_LIBRARY(transport-plugin SHARED ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ${EXTRA_SOURCES})
else()
ADD_LIBRARY(transport-plugin STATIC ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ../../src/memoryusage.cpp ${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc)
ADD_LIBRARY(transport-plugin STATIC ${HEADERS} ${SRC} ${PROTOBUF_SRC} ${PROTOBUF_HDRS} ${EXTRA_SOURCES})
endif()
ADD_DEPENDENCIES(transport-plugin pb)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/../../include/transport/protocol.pb.cc PROPERTIES GENERATED 1)

View file

@ -67,7 +67,21 @@ static void initLogging(Config *config, std::string key) {
}
else {
log4cxx::helpers::Properties p;
log4cxx::helpers::FileInputStream *istream = new log4cxx::helpers::FileInputStream(CONFIG_STRING(config, key));
log4cxx::helpers::FileInputStream *istream = NULL;
try {
istream = new log4cxx::helpers::FileInputStream(CONFIG_STRING(config, key));
}
catch(log4cxx::helpers::IOException &ex) {
std::cerr << "Can't create FileInputStream logger instance: " << ex.what() << "\n";
}
catch (...) {
std::cerr << "Can't create FileInputStream logger instance\n";
}
if (!istream) {
return;
}
p.load(istream);
LogString pid, jid;

View file

@ -1095,12 +1095,13 @@ void NetworkPluginServer::handleUserDestroyed(User *user) {
}
send(c->connection, message);
c->users.remove(user);
// if (c->users.size() == 0) {
// LOG4CXX_INFO(logger, "Disconnecting backend " << c << ". There are no users.");
// handleSessionFinished(c);
// m_clients.erase(user->connection);
// }
// If backend should handle only one user, it must not accept another one before
// we kill it, so set up willDie to true
if (c->users.size() == 0 && CONFIG_INT(m_config, "service.users_per_backend") == 1) {
LOG4CXX_INFO(logger, "Backend " << c->id << " will die, because the last user disconnected");
c->willDie = true;
}
}
void NetworkPluginServer::handleMessageReceived(NetworkConversation *conv, boost::shared_ptr<Swift::Message> &msg) {