lusa 5 éve
szülő
commit
5751f98acc

+ 2 - 1
app/goahead-5.1.0/src/goahead.c

@@ -150,7 +150,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
     }
 #endif
     logHeader();
-	error("---> argind = %d, argc = %d\n", argind, argc);
+	printf("---> argind = %d, argc = %d\n", argind, argc);
     if (argind < argc) {
         while (argind < argc) {
             endpoint = argv[argind++];
@@ -166,6 +166,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
             if (strstr(endpoint, "https")) continue;
 #endif
             if (websListen(endpoint) < 0) {
+                printf("websListen>>>>>>>>>>>>>>endpoint>>>>%s\n", endpoint);
                 wfree(endpoints);
                 return -1;
             }

+ 9 - 11
app/goahead-5.1.0/src/http.c

@@ -649,6 +649,9 @@ PUBLIC int websListen(cchar *endpoint)
         error("Too many listen endpoints");
         return -1;
     }
+
+
+    printf("socket ++++++++++++++++++>%s\n", endpoint);
     socketParseAddress(endpoint, &ip, &port, &secure, 80);
 	error("---> ip: %s, port: %d, secure: %d\n", ip, port, secure);
     if ((sid = socketListen(ip, port, websAccept, 0)) < 0) {
@@ -1638,13 +1641,13 @@ PUBLIC void websResponse(Webs *wp, int code, cchar *message)
         websWriteBlock(wp, message, len);
         websWriteBlock(wp, "\r\n", 2);
 
-        // websWrite(wp, message);
+        websWrite(wp, message);
        
     } else {
         logmsg(2,"-----------------------response 2-----------------------%s", message);
         websWriteHeaders(wp, 0, 0);
         websWriteEndHeaders(wp);
-        // websWriteBlock(wp, message, len);
+        websWriteBlock(wp, message, len);
     }
     websDone(wp);
 }
@@ -1889,7 +1892,6 @@ PUBLIC void websSetStatus(Webs *wp, int code)
 PUBLIC void websWriteHeaders(Webs *wp, ssize length, cchar *location)
 {
 
-     printf("-------------writeHead------0-----------------s\n");
     WebsKey     *cookie, *key, *next;
     char        *date, *protoVersion;
 
@@ -1985,8 +1987,6 @@ PUBLIC void websSetTxLength(Webs *wp, ssize length)
  */
 PUBLIC ssize websWrite(Webs *wp, cchar *fmt, ...)
 {
-
-     printf("-------------writebody------0-----------------s\n" );
     va_list     vargs;
     char        *buf;
     ssize       rc;
@@ -2004,7 +2004,6 @@ PUBLIC ssize websWrite(Webs *wp, cchar *fmt, ...)
     va_end(vargs);
     assert(buf);
     if (buf) {
-        printf("-------------writebody------1-----------------s\n" );
         rc = websWriteBlock(wp, buf, strlen(buf));
         wfree(buf);
     }
@@ -2119,7 +2118,6 @@ static bool flushChunkData(Webs *wp)
 PUBLIC int websFlush(Webs *wp, bool block)
 {
 
-    logmsg(2, "-----------------websFlush--1----------------\n");
     WebsBuf     *op;
     ssize       nbytes, written;
     int         errCode, wasBlocking;
@@ -2137,7 +2135,6 @@ PUBLIC int websFlush(Webs *wp, bool block)
             wp->flags &= ~WEBS_CHUNKING;
         }
     }
-    logmsg(2, "-----------------websFlush--2----------------\n");
     trace(6, "websFlush: buflen %d", bufLen(op));
     written = 0;
     while ((nbytes = bufLen(op)) > 0) {
@@ -2163,13 +2160,11 @@ PUBLIC int websFlush(Webs *wp, bool block)
         bufCompact(op);
         nbytes = bufLen(op);
     }
-    logmsg(2, "-----------------websFlush--3----------------\n");
     assert(websValid(wp));
 
     if (bufLen(op) == 0 && wp->finalized) {
         wp->state = WEBS_COMPLETE;
     }
-    logmsg(2, "-----------------websFlush--4----------------\n");
     if (block) {
         socketSetBlock(wp->sid, wasBlocking);
     }
@@ -2265,6 +2260,7 @@ PUBLIC ssize websWriteBlock(Webs *wp, cchar *buf, ssize size)
         buf += thisWrite;
         written += thisWrite;
     }
+
     bufAddNull(op);
     if (wp->state >= WEBS_COMPLETE && written == 0) {
         return -1;
@@ -2391,7 +2387,7 @@ static void checkTimeout(void *arg, int id)
 
     printf("<<<<<<<<<checkTimeout<<<<websDebug<<<<>>%#x\n", websDebug);
     elapsed = getTimeSinceMark(wp) * 1000;
-    if (1) {
+    if (websDebug) {
         websRestartEvent(id, (int) WEBS_TIMEOUT);
         return;
     }
@@ -3450,6 +3446,8 @@ PUBLIC int websServer(cchar *endpoint, cchar *documents)
 {
     int     finished = 0;
 
+
+    printf("websServer>>>>>>>>>>>>>>>>>>%s\n", documents);
     if (websOpen(documents, "route.txt") < 0) {
         error("Cannot initialize server. Exiting.");
         return -1;

+ 0 - 3
app/goahead-5.1.0/src/route.c

@@ -94,7 +94,6 @@ PUBLIC void websRouteRequest(Webs *wp)
 {
 
     // logmsg(2,"——————————————————————0————————————");
-    logmsg(2, "-----------------------222----------------------");
     WebsRoute   *route;
     WebsHandler *handler;
     ssize       plen, len;
@@ -108,7 +107,6 @@ PUBLIC void websRouteRequest(Webs *wp)
 
     safeMethod = smatch(wp->method, "POST") || smatch(wp->method, "GET") || smatch(wp->method, "HEAD");
     plen = slen(wp->path);
-        logmsg(2, "-----------------------0.1----------------------");
     /*
         Resume routine from last matched route. This permits the legacy service() callbacks to return false
         and continue routing.
@@ -163,7 +161,6 @@ PUBLIC void websRouteRequest(Webs *wp)
         }
 
         wp->route = route;
-         logmsg(2,"-----------------------11-----------------------");
 #if ME_GOAHEAD_AUTH
         logmsg(2,"-----------------------22-----111-------%#X-----------", route->authType);
         if (route->authType) {

+ 1 - 0
app/goahead-5.1.0/src/socket.c

@@ -51,6 +51,7 @@ PUBLIC int socketOpen(void)
     socketHighestFd = -1;
 	error("---> socketOpen\n");
     if ((fd = socket(AF_INET, SOCK_STREAM, 0)) != -1) {
+        printf("---> closesocket\n");
         closesocket(fd);
     } else {
         trace(1, "This system does not have IPv6 support");

+ 28 - 12
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -47,6 +47,9 @@ void getDeviceInfo(Webs *wp){
         printf("IpAddr: %s\n", IpAddr);
     }
 
+    //Close session
+    LIBIPMI_CloseSession(&UDSSession );
+
     // //get mac address
     // if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
     // {
@@ -93,8 +96,7 @@ void getDeviceInfo(Webs *wp){
     // }
     // close(sock);
     
-    //Close session
-    LIBIPMI_CloseSession(&UDSSession );
+    
 
 
     printf("BuildTime: %s\n", BuildTime);
@@ -102,20 +104,26 @@ void getDeviceInfo(Webs *wp){
     printf("MacAddr: %s\n", MacAddr);
     printf("IpAddr: %s\n", IpAddr);
 
-    cchar *pStr;
+    char *pStr;
+
+    char *testStr;
+    testStr = malloc(200); 
+    sprintf(testStr, "%s", "jimbo is very confused!");
+
     int code = 200;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
     // cJSON * next =  cJSON_CreateObject();
-    cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
-    cJSON_AddStringToObject(data, "buildTime", BuildTime);
-    cJSON_AddStringToObject(data, "fwVersion", FwVersion);
-    cJSON_AddStringToObject(data, "macAddr", MacAddr);
-    cJSON_AddStringToObject(data, "ipAddr", IpAddr);
+    // cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
+    // cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+    // cJSON_AddStringToObject(data, "buildTime", BuildTime);
+    // cJSON_AddStringToObject(data, "fwVersion", FwVersion);
+    // cJSON_AddStringToObject(data, "macAddr", MacAddr);
+    // cJSON_AddStringToObject(data, "ipAddr", IpAddr);
 
-    pStr = cJSON_Print(root);
+    //pStr = cJSON_Print(root);
+    pStr = testStr;
 
     printf("first json:\n%s\n", pStr);
     logmsg(2, "-----------------------jso1n----------------------%s", pStr);
@@ -128,11 +136,18 @@ void getDeviceInfo(Webs *wp){
     //websWrite(wp, "]");
     websFlush(wp, 0);
     websDone(wp);
+
+    if(pStr)
+        free(pStr);
+    
 }
 
 
 /*获取系统信息*/
 void getSysInfo(Webs *wp){
+
+
+    printf("lisentid value is %d\n", wp->listenSid);
     int wRet;
     SysInfo_T sysInfo;
     uint8_t Req[5] = {0,0,0,0,0};
@@ -472,7 +487,7 @@ void actionTest(Webs *wp)
     char IpAddr[16] = "192.168.255.255";
 
     //Create session
-    // printf("actionTest!\n");
+
     // LIBIPMI_CreateSession(&UDSSession, 10);
     // IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
     // LIBIPMI_CloseSession(&UDSSession );
@@ -512,6 +527,7 @@ void actionTest(Webs *wp)
  //    pStr = cJSON_Print(root);     //include malloc
     
     printf("%s\n", pStr);
+
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);