diff --git a/ChangeLog b/ChangeLog index 0e9ea789..11d5547c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-08-28 Tatsuhiro Tsujikawa + + Changed signature of util::executeHook(). + * src/RequestGroupMan.cc + * src/util.cc + * src/util.h + 2010-08-28 Tatsuhiro Tsujikawa Wait data arrives at clientSocket_ in diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index a1a8f6a4..4bf4b08f 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -255,12 +255,15 @@ static void executeStopHook { if(result->result == downloadresultcode::FINISHED && !option->blank(PREF_ON_DOWNLOAD_COMPLETE)) { - util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE), result->gid); + util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE), + util::itos(result->gid)); } else if(result->result != downloadresultcode::IN_PROGRESS && !option->blank(PREF_ON_DOWNLOAD_ERROR)) { - util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR), result->gid); + util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR), + util::itos(result->gid)); } else if(!option->blank(PREF_ON_DOWNLOAD_STOP)) { - util::executeHook(option->get(PREF_ON_DOWNLOAD_STOP), result->gid); + util::executeHook(option->get(PREF_ON_DOWNLOAD_STOP), + util::itos(result->gid)); } } diff --git a/src/util.cc b/src/util.cc index 9c12c6a3..6a0944e4 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1346,17 +1346,17 @@ void removeMetalinkContentTypes(const SharedHandle& group) } } -void executeHook(const std::string& command, gid_t gid) +void executeHook(const std::string& command, const std::string& arg) { LogFactory::getInstance()->info("Executing user command: %s %s", - command.c_str(), util::itos(gid).c_str()); + command.c_str(), arg.c_str()); #ifndef __MINGW32__ pid_t cpid = fork(); if(cpid == -1) { LogFactory::getInstance()->error("fork() failed." " Cannot execute user command."); } else if(cpid == 0) { - execl(command.c_str(), command.c_str(), util::itos(gid).c_str(), + execl(command.c_str(), command.c_str(), arg.c_str(), reinterpret_cast(0)); perror(("Could not execute user command: "+command).c_str()); exit(EXIT_FAILURE); @@ -1371,7 +1371,7 @@ void executeHook(const std::string& command, gid_t gid) memset(&pi, 0, sizeof (pi)); std::string cmdline = command; - strappend(cmdline, " ", util::itos(gid)); + strappend(cmdline, " ", arg); DWORD rc = CreateProcess( NULL, @@ -1402,7 +1402,7 @@ void executeHookByOptName (const RequestGroup* group, const Option* option, const std::string& opt) { if(!option->blank(opt)) { - executeHook(option->get(opt), group->getGID()); + executeHook(option->get(opt), util::itos(group->getGID())); } } diff --git a/src/util.h b/src/util.h index 1cbfa546..af241569 100644 --- a/src/util.h +++ b/src/util.h @@ -396,7 +396,7 @@ bool inSameCidrBlock(const std::string& ip1, const std::string& ip2, int bits); void removeMetalinkContentTypes(const SharedHandle& group); -void executeHook(const std::string& command, gid_t gid); +void executeHook(const std::string& command, const std::string& arg); void executeHookByOptName (const SharedHandle& group, const Option* option,