projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Z39.50 client: fix NULL ptr reference.
[metaproxy-moved-to-github.git]
/
src
/
filter_cgi.cpp
diff --git
a/src/filter_cgi.cpp
b/src/filter_cgi.cpp
index
3747e63
..
7cec0cd
100644
(file)
--- a/
src/filter_cgi.cpp
+++ b/
src/filter_cgi.cpp
@@
-24,6
+24,7
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <yaz/log.h>
#include <unistd.h>
#include <yaz/log.h>
#include <unistd.h>
+#include <signal.h>
#include <sys/wait.h>
#include <sstream>
#include <sys/wait.h>
#include <sstream>
@@
-43,17
+44,30
@@
namespace metaproxy_1 {
class CGI::Rep {
friend class CGI;
std::list<CGI::Exec> exec_map;
class CGI::Rep {
friend class CGI;
std::list<CGI::Exec> exec_map;
+ std::map<pid_t,pid_t> children;
+ boost::mutex m_mutex;
+ public:
+ ~Rep();
};
}
}
yf::CGI::CGI() : m_p(new Rep)
{
};
}
}
yf::CGI::CGI() : m_p(new Rep)
{
+
+}
+yf::CGI::Rep::~Rep()
+{
+ std::map<pid_t,pid_t>::const_iterator it;
+ boost::mutex::scoped_lock lock(m_mutex);
+
+ for (it = children.begin(); it != children.end(); it++)
+ kill(it->second, SIGTERM);
}
yf::CGI::~CGI()
}
yf::CGI::~CGI()
-{ // must have a destructor because of boost::scoped_ptr
+{
}
void yf::CGI::process(mp::Package &package) const
}
void yf::CGI::process(mp::Package &package) const
@@
-91,7
+105,7
@@
void yf::CGI::process(mp::Package &package) const
int r;
pid_t pid;
int status;
int r;
pid_t pid;
int status;
-
+
pid = ::fork();
switch (pid)
{
pid = ::fork();
switch (pid)
{
@@
-109,8
+123,18
@@
void yf::CGI::process(mp::Package &package) const
package.response() = zgdu_res;
break;
default: /* parent */
package.response() = zgdu_res;
break;
default: /* parent */
+ if (pid)
+ {
+ boost::mutex::scoped_lock lock(m_p->m_mutex);
+ m_p->children[pid] = pid;
+ }
waitpid(pid, &status, 0);
waitpid(pid, &status, 0);
+ if (pid)
+ {
+ boost::mutex::scoped_lock lock(m_p->m_mutex);
+ m_p->children.erase(pid);
+ }
zgdu_res = odr.create_HTTP_Response(
package.session(), zgdu_req->u.HTTP_Request, 200);
package.response() = zgdu_res;
zgdu_res = odr.create_HTTP_Response(
package.session(), zgdu_req->u.HTTP_Request, 200);
package.response() = zgdu_res;