Changeset - 2dc2e27d24ef
[Not reviewed]
default
0 3 0
ethanzonca@ethanzonca.protofusion.org - 16 years ago 2009-12-14 18:54:36
ethanzonca@ethanzonca.protofusion.org
Updated signals to be char, added extended signal sending
3 files changed with 35 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -108,13 +108,13 @@ int main(int argc, char *argv[])
 
  options_init(argc, argv, &my_cfg, myopts, "slave", &commonopts);
 

	
 

	
 
  /* Notifies the user if there no username in .conf */
 
  if(username == NULL || strcmp(username, "!username") == 0 )
 
    fprintf(stderr, "\nPlease ensure that your username is present in distrenslave.conf\n");
 
  else 
 
  else
 
    if( username != NULL || strcmp(username, "!username") != 0 )
 
      {
 
	// Log in the user
 
	if(login_user(username) == 1){
 
	  fprintf(stderr, "You should now be logged into distren.\n");
 
	}
 
@@ -129,19 +129,19 @@ int main(int argc, char *argv[])
 
	fprintf(stderr, "Please check your distrenslave.conf, it appears to be incorrectly formatted.\n");
 
      }
 

	
 

	
 

	
 
  fprintf(stderr, "Loading config (fasten your seatbelts for a SEGFAULT :-D )...\n");
 
  
 

	
 

	
 
  fprintf(stderr, "Connecting to server...\n");
 
  tmp = remoteio_open(&comm_slave, commonopts->remoteio, server);
 
  if(tmp)
 
    {
 
      fprintf(stderr, "Error connecting to server; exitting\n");
 
      fprintf(stderr, "Error connecting to server; exiting\n");
 
      return 1;
 
    }
 

	
 
  int haveWork = 0;
 

	
 
  while(1)
src/server/slavefuncs.c
Show inline comments
 
@@ -36,19 +36,19 @@
 
#include <fcntl.h>
 

	
 

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

	
 
  _distren_asprintf(&ssignal, "%d", signal);
 
  _distren_asprintf(&ssignal, "%c", signal);
 
  towrite = strlen(ssignal);
 
  while( towrite
 
	 && !remoteio_write(rem, ssignal, towrite, &written))
 
    {
 
      printf(stderr, "Writing...");
 
      towrite -= written;
 
@@ -59,12 +59,40 @@ int sendSignal(struct remoteio *rem, int
 
  /**
 
     if remoteio_write returned 1, the connection
 
     is probably dead or there was a real error
 
   */
 
  return 1;
 
}
 

	
 
/**
 
   Sends the server an extended signal (request + data)
 
*/
 
int sendExtSignal(struct remoteio *rem, char signal, char *data){
 
  size_t written;
 
  size_t towrite;
 
  char *ssignal;
 
  _distren_asprintf(&ssignal, "%c%s", signal, data); // Just append the data FIXME: We should do this differently
 
  towrite = strlen(ssignal);
 
  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;
src/server/slavefuncs.h
Show inline comments
 
@@ -25,13 +25,14 @@
 

	
 
#include <libxml/xpath.h>
 
#include <stdio.h>
 

	
 

	
 
struct msg;
 
int sendSignal(struct remoteio *rem, int signal);
 
int sendSignal(struct remoteio *rem, char signal);
 
int sendExtSignal(struct remoteio *rem, char signal, char *data);
 
xmlNodePtr xml_quickxpath(xmlXPathContextPtr xpathctxt, xmlChar *path);
 
int software_updatecheck();
 
int delete_jobdata(int jobnum, char *datadir);
 
size_t curl_writetodisk(void *ptr, size_t size, size_t nmemb, FILE *stream);
 
int curlget(char *url, char *out);
 
int curlpost(char *filename, char *url);
0 comments (0 inline, 0 general)