Changeset - 262e6275036b
[Not reviewed]
default
0 3 0
Nathan Brink (binki) - 16 years ago 2009-12-12 17:45:38
ohnobinki@ohnopublishing.net
fix sendSignal() use of remoteio, config
3 files changed with 13 insertions and 5 deletions:
0 comments (0 inline, 0 general)
etc/distrenslave.conf.in
Show inline comments
 
slave
 
{
 
  username = "!username"
 
  datadir = "@LOCALSTATEDIR@/@PACKAGE@"
 
  hostname = "protofusion.org"
 
  server = "protofusion"
 
}
 

	
 
include("distrencommon.conf")
src/common/remoteio.h
Show inline comments
 
@@ -29,24 +29,26 @@
 
struct remoteio_opts;
 
struct remoteio;
 

	
 
/**
 
   Opens connection with remote distrend. Returns 1 on error.
 

	
 
   @todo should this be asynchronous?
 
 */
 
int remoteio_open(struct remoteio **rem, struct remoteio_opts *opts, const char *servername);
 

	
 
/**
 
   non-blocking I/O.
 
   @return 0 on success, 1 on failure
 
   @param len must be greater than 0
 

	
 
   @return 0 on success, 1 on failure. 
 
 */
 
int remoteio_read(struct remoteio *rem, void *buf, size_t len, size_t *bytesread);
 
int remoteio_write(struct remoteio *rem, void *buf, size_t len, size_t *byteswritten);
 

	
 
/**
 
   Closes a remoteio session.
 
   @return nonzero on error
 
*/
 
int remoteio_close(struct remoteio *rem);
 

	
 
#endif
src/server/slavefuncs.c
Show inline comments
 
@@ -38,32 +38,38 @@
 

	
 
/**
 
   Sends the server a single request (see protocol.h)
 
*/
 
int sendSignal(struct remoteio *rem, int signal)
 
{
 
  size_t written;
 
  size_t towrite;
 
  char *ssignal;
 

	
 
  _distren_asprintf(&ssignal, "%d", signal);
 
  towrite = strlen(ssignal);
 
  while( !remoteio_write(rem, ssignal, towrite, &written)
 
	 && towrite
 
	 && written)
 
  while( towrite
 
	 && !remoteio_write(rem, ssignal, towrite, &written))
 
    {
 
      printf(stderr, "Writing...");
 
      towrite -= written;
 
    }
 
  if(written)
 
  return 0;
 

	
 
  /**
 
     if remoteio_write returned 1, the connection
 
     is probably dead or there was a real error
 
   */
 
  return 1;
 
}
 
/**
 
 utility function for XPath-ish stuff:
 
 */
 
xmlNodePtr xml_quickxpath(xmlXPathContextPtr xpathctxt, xmlChar *path)
 
{
 
  xmlNodePtr toreturn;
 

	
 
  xmlXPathObjectPtr xmlxpathobjptr;
 
  xmlxpathobjptr = xmlXPathEval(path, xpathctxt);
 
  if(!xmlxpathobjptr
 
     || !xmlxpathobjptr->nodesetval->nodeNr)
0 comments (0 inline, 0 general)