mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 22:59:21 +00:00
* Fixed EINTR handling in execute command. Patch by anonymous.
* Fixed a couple of memory leaks in xmlrpc.cc. Reported by Novik. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1057 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <rak/error_number.h>
|
||||||
#include <rak/path.h>
|
#include <rak/path.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@@ -90,8 +91,12 @@ ExecFile::execute(const char* file, char* const* argv) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
int status;
|
int status;
|
||||||
|
int wpid = waitpid(childPid, &status, 0);
|
||||||
|
|
||||||
if (waitpid(childPid, &status, 0) != childPid)
|
while (wpid == -1 && rak::error_number::current().value() == rak::error_number::e_intr)
|
||||||
|
wpid = waitpid(childPid, &status, 0);
|
||||||
|
|
||||||
|
if (wpid != childPid)
|
||||||
throw torrent::internal_error("ExecFile::execute(...) waitpid failed.");
|
throw torrent::internal_error("ExecFile::execute(...) waitpid failed.");
|
||||||
|
|
||||||
// Check return value?
|
// Check return value?
|
||||||
|
|||||||
+1
-1
@@ -373,7 +373,7 @@ print_object(char* first, char* last, const torrent::Object* src, int flags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case torrent::Object::TYPE_VALUE:
|
case torrent::Object::TYPE_VALUE:
|
||||||
return std::max(first + snprintf(first, std::distance(first, last), "%lli", src->as_value()), last);
|
return std::min(first + snprintf(first, std::distance(first, last), "%lli", src->as_value()), last);
|
||||||
|
|
||||||
case torrent::Object::TYPE_LIST:
|
case torrent::Object::TYPE_LIST:
|
||||||
for (torrent::Object::list_const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
for (torrent::Object::list_const_iterator itr = src->as_list().begin(), itrEnd = src->as_list().end(); itr != itrEnd; itr++) {
|
||||||
|
|||||||
+10
-4
@@ -377,8 +377,11 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
|||||||
{
|
{
|
||||||
xmlrpc_value* result = xmlrpc_array_new(env);
|
xmlrpc_value* result = xmlrpc_array_new(env);
|
||||||
|
|
||||||
for (torrent::Object::list_const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++)
|
for (torrent::Object::list_const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++) {
|
||||||
xmlrpc_array_append_item(env, result, object_to_xmlrpc(env, *itr));
|
xmlrpc_value* item = object_to_xmlrpc(env, *itr);
|
||||||
|
xmlrpc_array_append_item(env, result, item);
|
||||||
|
xmlrpc_DECREF(item);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -387,8 +390,11 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) {
|
|||||||
{
|
{
|
||||||
xmlrpc_value* result = xmlrpc_struct_new(env);
|
xmlrpc_value* result = xmlrpc_struct_new(env);
|
||||||
|
|
||||||
for (torrent::Object::map_const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++)
|
for (torrent::Object::map_const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++) {
|
||||||
xmlrpc_struct_set_value(env, result, itr->first.c_str(), object_to_xmlrpc(env, itr->second));
|
xmlrpc_value* item = object_to_xmlrpc(env, itr->second);
|
||||||
|
xmlrpc_struct_set_value(env, result, itr->first.c_str(), item);
|
||||||
|
xmlrpc_DECREF(item);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user