fixed 64bit issue with file descriptor
[strongswan.git] / src / charon / control / interfaces / xml_interface.c
index 389aeed..7710ae1 100644 (file)
@@ -189,6 +189,7 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
                {
                        write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_HERE));
                }
                {
                        write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_HERE));
                }
+               xmlTextWriterEndElement(writer);
                /* </local> */
                
                /* <remote> */
                /* </local> */
                
                /* <remote> */
@@ -205,6 +206,7 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
                {
                        write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_THERE));
                }
                {
                        write_bool(writer, "nat", ike_sa->has_condition(ike_sa, COND_NAT_THERE));
                }
+               xmlTextWriterEndElement(writer);
                /* </remote> */         
                
                /* <childsalist> */
                /* </remote> */         
                
                /* <childsalist> */
@@ -286,8 +288,14 @@ static void request(xmlTextReaderPtr reader, char *id, int fd)
        /*   </message> and close document */
        xmlTextWriterEndDocument(writer);
        xmlFreeTextWriter(writer);
        /*   </message> and close document */
        xmlTextWriterEndDocument(writer);
        xmlFreeTextWriter(writer);
-       /* write a newline to indicate end of xml */
-       write(fd, "\n", 1);
+}
+
+/**
+ * cleanup helper function for open file descriptors
+ */
+static void closefdp(int *fd)
+{
+       close(*fd);
 }
 
 /**
 }
 
 /**
@@ -301,7 +309,7 @@ static job_requeue_t process(int *fdp)
        xmlTextReaderPtr reader;
        char *id = NULL, *type = NULL;
        
        xmlTextReaderPtr reader;
        char *id = NULL, *type = NULL;
        
-       pthread_cleanup_push((void*)close, (void*)fd);
+       pthread_cleanup_push((void*)closefdp, (void*)&fd);
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = read(fd, buffer, sizeof(buffer));
        pthread_setcancelstate(oldstate, NULL);
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
        len = read(fd, buffer, sizeof(buffer));
        pthread_setcancelstate(oldstate, NULL);
@@ -312,6 +320,7 @@ static job_requeue_t process(int *fdp)
                DBG2(DBG_CFG, "SMP XML connection closed");
                return JOB_REQUEUE_NONE;
        }
                DBG2(DBG_CFG, "SMP XML connection closed");
                return JOB_REQUEUE_NONE;
        }
+       DBG1(DBG_CFG, "got XML request: %b", buffer, len);
        
        reader = xmlReaderForMemory(buffer, len, NULL, NULL, 0);
        if (reader == NULL)
        
        reader = xmlReaderForMemory(buffer, len, NULL, NULL, 0);
        if (reader == NULL)