Changeset 1057

Show
Ignore:
Timestamp:
05/01/08 13:14:43 (4 years ago)
Author:
rakshasa
Message:

* Fixed EINTR handling in execute command. Patch by anonymous.

* Fixed a couple of memory leaks in xmlrpc.cc. Reported by Novik.

Location:
trunk/rtorrent/src/rpc
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/rtorrent/src/rpc/exec_file.cc

    r1000 r1057  
    3939#include <string> 
    4040#include <unistd.h> 
     41#include <rak/error_number.h> 
    4142#include <rak/path.h> 
    4243#include <sys/types.h> 
     
    9192  } else { 
    9293    int status; 
     94    int wpid = waitpid(childPid, &status, 0); 
    9395 
    94     if (waitpid(childPid, &status, 0) != childPid) 
     96    while (wpid == -1 && rak::error_number::current().value() == rak::error_number::e_intr) 
     97      wpid = waitpid(childPid, &status, 0); 
     98 
     99    if (wpid != childPid) 
    95100      throw torrent::internal_error("ExecFile::execute(...) waitpid failed."); 
    96101 
  • trunk/rtorrent/src/rpc/parse.cc

    r1038 r1057  
    374374 
    375375  case torrent::Object::TYPE_VALUE: 
    376     return std::max(first + snprintf(first, std::distance(first, last), "%lli", src->as_value()), last); 
     376    return std::min(first + snprintf(first, std::distance(first, last), "%lli", src->as_value()), last); 
    377377 
    378378  case torrent::Object::TYPE_LIST: 
  • trunk/rtorrent/src/rpc/xmlrpc.cc

    r1050 r1057  
    378378    xmlrpc_value* result = xmlrpc_array_new(env); 
    379379     
    380     for (torrent::Object::list_const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++) 
    381       xmlrpc_array_append_item(env, result, object_to_xmlrpc(env, *itr)); 
     380    for (torrent::Object::list_const_iterator itr = object.as_list().begin(), last = object.as_list().end(); itr != last; itr++) { 
     381      xmlrpc_value* item = object_to_xmlrpc(env, *itr); 
     382      xmlrpc_array_append_item(env, result, item); 
     383      xmlrpc_DECREF(item); 
     384    } 
    382385 
    383386    return result; 
     
    388391    xmlrpc_value* result = xmlrpc_struct_new(env); 
    389392     
    390     for (torrent::Object::map_const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++) 
    391       xmlrpc_struct_set_value(env, result, itr->first.c_str(), object_to_xmlrpc(env, itr->second)); 
     393    for (torrent::Object::map_const_iterator itr = object.as_map().begin(), last = object.as_map().end(); itr != last; itr++) { 
     394      xmlrpc_value* item = object_to_xmlrpc(env, itr->second); 
     395      xmlrpc_struct_set_value(env, result, itr->first.c_str(), item); 
     396      xmlrpc_DECREF(item); 
     397    } 
    392398 
    393399    return result;