Changeset 1773

Show
Ignore:
Timestamp:
08/28/08 12:34:20 (3 months ago)
Author:
xkovah
Message:

sending back all event lists at once now. But I just noticed that if I make 2 reg events and then ask for 1 in one query and then ask for 1 in a second query, the second query has junk data. I think it's probably cause I didn't yet make the elements which go into the lists be soap-allocated…so I will try that and see what happens

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • capture-mod/trunk/CaptureSoapServer.cpp

    r1771 r1773  
    8686 
    8787    //now begins the arduous process of converting the values into char *s 
     88    //TODO: use a soap function to make r 
    8889    ns__regEvent_t r; 
    89     //TODO: trace through and verify that all mallocs are cleaned up by the soap code 
    90     r.time = (char *)malloc(time.length()+1); 
     90    r.time = (char *)soap_malloc(&soap,time.length()+1); 
    9191    sprintf(r.time, "%ls", time.c_str()); 
    92     printf("r.time = %s\n", r.time); 
    93  
    94     r.eventType = (char *)malloc(registryEventType.length()+1); 
     92 
     93    r.eventType = (char *)soap_malloc(&soap,registryEventType.length()+1); 
    9594    sprintf(r.eventType, "%ls", registryEventType.c_str()); 
    9695 
    97     char * tmp = (char *)malloc(extra.at(0).length()+1); 
     96    char * tmp = (char *)soap_malloc(&soap,extra.at(0).length()+1); 
    9897    sprintf(tmp, "%ls", extra.at(0).c_str()); 
    9998    r.procPID = atoi(tmp); 
    100     printf("r.procPID = %d\n", r.procPID); 
    10199    free(tmp); 
    102100 
    103     r.procName = (char *)malloc(processPath.length()+1); 
     101    r.procName = (char *)soap_malloc(&soap,processPath.length()+1); 
    104102    sprintf(r.procName, "%ls", processPath.c_str()); 
    105103 
    106     r.keyName = (char *)malloc(registryEventPath.length()+1); 
     104    r.keyName = (char *)soap_malloc(&soap,registryEventPath.length()+1); 
    107105    sprintf(r.keyName, "%ls", registryEventPath.c_str()); 
    108106 
    109     r.valueName = (char *)malloc(extra.at(1).length()+1); 
     107    r.valueName = (char *)soap_malloc(&soap,extra.at(1).length()+1); 
    110108    sprintf(r.valueName, "%ls", extra.at(1).c_str()); 
    111109 
    112     r.valueType = (char *)malloc(extra.at(2).length()+1); 
     110    r.valueType = (char *)soap_malloc(&soap,extra.at(2).length()+1); 
    113111    sprintf(r.valueType, "%ls", extra.at(2).c_str()); 
    114112 
    115     r.valueData = (char *)malloc(extra.at(3).length()+1); 
     113    r.valueData = (char *)soap_malloc(&soap,extra.at(3).length()+1); 
    116114    sprintf(r.valueData, "%ls", extra.at(3).c_str()); 
    117115 
     
    127125{ 
    128126    printf("CaptureSoapServer::onFileEvent got an event for time = %ls\n", time.c_str()); 
     127    ns__fileEvent_t f; 
     128    f.time = (char *)soap_malloc(&soap,time.length()+1); 
     129    sprintf(f.time, "%ls", time.c_str()); 
     130 
     131    f.eventType = (char *)soap_malloc(&soap,fileEventType.length()+1); 
     132    sprintf(f.eventType, "%ls", fileEventType.c_str()); 
     133 
     134    char * tmp = (char *)malloc(extra.at(0).length()+1); 
     135    sprintf(tmp, "%ls", extra.at(0).c_str()); 
     136    f.procPID = atoi(tmp); 
     137    free(tmp); 
     138 
     139    f.procName = (char *)soap_malloc(&soap,processPath.length()+1); 
     140    sprintf(f.procName, "%ls", processPath.c_str()); 
     141 
     142    f.fileName = (char *)soap_malloc(&soap,fileEventPath.length()+1); 
     143    sprintf(f.fileName, "%ls", fileEventPath.c_str()); 
     144 
     145    fileList.push_back(f); 
     146    printf("added one event to fileList. Now there are %d elements in the list\n", fileList.size()); 
     147 
     148 
    129149} 
    130150 
     
    134154{ 
    135155    printf("CaptureSoapServer::onProcessEvent got an event for time = %ls\n", time.c_str()); 
     156    ns__procEvent_t p; 
     157    p.time = (char *)soap_malloc(&soap,time.length()+1); 
     158    sprintf(p.time, "%ls", time.c_str()); 
     159 
     160    p.eventType = (char *)soap_malloc(&soap,11); //11 == max length == "terminated" 
     161    if(created){ 
     162        sprintf(p.eventType, "created"); 
     163    } 
     164    else{ 
     165        sprintf(p.eventType, "terminated"); 
     166    } 
     167 
     168    p.parentPID = parentProcessId; 
     169 
     170    p.parentName = (char *)soap_malloc(&soap,parentProcess.length()+1); 
     171    sprintf(p.parentName, "%ls", parentProcess.c_str()); 
     172 
     173    p.procPID = processId; 
     174 
     175    p.procName = (char *)soap_malloc(&soap,process.length()+1); 
     176    sprintf(p.procName, "%ls", process.c_str()); 
     177 
     178    procList.push_back(p); 
     179    printf("added one event to procList. Now there are %d elements in the list\n", procList.size()); 
     180 
    136181} 
    137182 
     
    332377 
    333378//If maxEventsReturned == -1, then then send as many as possible. 
    334 //TODO: Make SOAP::Lite understand unsigned int type, so that this (and other) ints can be set as such 
    335379int ns__returnEvents(struct soap *soap, int maxEventsToReturn, struct ns__allEvents &result){ 
     380    char debug = 0; 
     381 
    336382    struct ns__allEvents * all = soap_new_ns__allEvents(soap, 1); 
    337383    all->regEvents = NULL; 
     
    350396        all->regEvents = dRegArray; 
    351397 
    352         printf("dRegArray->__size = %d, maxEventsToReturn = %d\n", dRegArray->__size, maxEventsToReturn); 
    353  
    354398        //Figure out how many entries we will send back 
    355         if(maxEventsToReturn == -1 || maxEventsToReturn > dRegArray->__size){ 
    356             dRegArray->__size = regList.size(); 
    357         } 
    358         else{ 
     399        if(maxEventsToReturn < dRegArray->__size && maxEventsToReturn != -1){ 
    359400            dRegArray->__size = maxEventsToReturn; 
    360401        } 
    361  
    362402        printf("Sending back %d registy events\n",dRegArray->__size); 
    363403 
    364         //don't want to call the size function more times than we have to 
     404        //Allocate a flat array to hold our ns__regEvents in 
     405        //TODO: see if soap_new_ns__regEvent(soap, dRegArray->__size) works 
    365406        struct ns__regEvent * ns__regEventArray = (struct ns__regEvent *)soap_malloc(soap, dRegArray->__size*sizeof(struct ns__regEvent)); 
    366  
    367407        dRegArray->__ptr = ns__regEventArray; 
    368408 
    369         int * b = (int *) ns__regEventArray; 
    370409        for(unsigned int i = 0; i < dRegArray->__size; i++){ 
     410            memcpy(&ns__regEventArray[i],&regList.front(), sizeof(struct ns__regEvent)); 
     411            regList.pop_front(); 
     412            if(debug){ 
    371413            printf("i = %d\n", i); 
    372414            printf("regList.front().time %s, %#x\n", regList.front().time, regList.front().time); 
     
    374416            printf("regList.front().procPID %d, %#x\n", regList.front().procPID, regList.front().procPID); 
    375417            printf("regList.front().procName %s, %#x\n", regList.front().procName, regList.front().procName); 
    376  
    377             memcpy(&ns__regEventArray[i],&regList.front(), sizeof(struct ns__regEvent)); 
    378             regList.pop_front(); 
    379             printf("%#x %#x %#x %#x\n", b[i*8+0], b[i*8+1], b[i*8+2], b[i*8+3]); 
     418            } 
    380419        } 
    381420    } 
     
    392431 
    393432        //Figure out how many entries we will send back 
    394         if(maxEventsToReturn == -1 || maxEventsToReturn > dFileArray->__size){ 
    395             dFileArray->__size = fileList.size(); 
    396         } 
    397         else{ 
     433        if(maxEventsToReturn < dFileArray->__size && maxEventsToReturn != -1){ 
    398434            dFileArray->__size = maxEventsToReturn; 
    399435        } 
    400  
    401436        printf("Sending back %d file events\n",dFileArray->__size); 
     437 
    402438        struct ns__fileEvent * ns__fileEventArray = (struct ns__fileEvent *)soap_malloc(soap, dFileArray->__size*sizeof(struct ns__fileEvent)); 
    403  
    404439        dFileArray->__ptr = ns__fileEventArray; 
    405440 
    406441        for(unsigned int i = 0; i < dFileArray->__size; i++){ 
    407442            memcpy(&ns__fileEventArray[i],&fileList.front(), sizeof(struct ns__fileEvent)); 
    408             regList.pop_front(); 
     443            fileList.pop_front(); 
    409444        } 
    410445    } 
     
    420455        all->procEvents = dProcArray; 
    421456 
    422         if(maxEventsToReturn == -1 || maxEventsToReturn > dProcArray->__size){ 
    423             dProcArray->__size = regList.size(); 
    424         } 
    425         else{ 
     457        if(maxEventsToReturn < dProcArray->__size && maxEventsToReturn != -1){ 
    426458            dProcArray->__size = maxEventsToReturn; 
    427459        } 
    428  
    429460        printf("Sending back %d process events\n",dProcArray->__size); 
    430461 
     
    434465        for(unsigned int i = 0; i < dProcArray->__size; i++){ 
    435466            memcpy(&ns__procEventArray[i],&procList.front(), sizeof(struct ns__procEvent)); 
    436             regList.pop_front(); 
     467            procList.pop_front(); 
    437468        } 
    438469    } 
  • capture-mod/trunk/CaptureSoapServer.h

    r1767 r1773  
    1313using namespace boost; 
    1414 
     15//While we could put typedefs in the definition, they don't follow through to the auto-generated 
     16//soap files. Therefore you would have to include captureGSOAP.h, but that would cause double definitions 
     17typedef struct ns__regEvent ns__regEvent_t; 
     18typedef struct ns__fileEvent ns__fileEvent_t; 
     19typedef struct ns__procEvent ns__procEvent_t; 
     20 
    1521class CaptureSoapServer : public Runnable 
    1622{ 
     
    2026    boost::signals::connection onFileEventConnection; 
    2127    boost::signals::connection onProcessEventConnection; 
    22     typedef struct ns__regEvent ns__regEvent_t; 
    23     typedef struct ns__fileEvent ns__fileEvent_t; 
    24     typedef struct ns__procEvent ns__procEvent_t; 
    25  
    2628 
    2729    CaptureSoapServer(Visitor *, RegistryMonitor * r, FileMonitor * f, ProcessMonitor * p);