Changeset 30381 for trunk/base


Ignore:
Timestamp:
Oct 26, 2007, 3:39:02 AM (12 years ago)
Author:
epimenov@…
Message:

tracelib: hackaround. Something strange happend, seems socket come broken after execve.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/darwintracelib1.0/darwintrace.c

    r28091 r30381  
    128128inline void __darwintrace_setup();
    129129inline void __darwintrace_cleanup_path(char *path);
    130 static char * exchange_with_port(const char * buf, size_t len, int answer);
     130static char * exchange_with_port(const char * buf, size_t len, int answer, char failures);
    131131
    132132#define START_FD 81
     
    320320static void ask_for_filemap()
    321321{
    322         filemap=exchange_with_port("filemap\t", sizeof("filemap\t"), 1);
     322        filemap=exchange_with_port("filemap\t", sizeof("filemap\t"), 1, 0);
    323323        if((int)filemap==-1)
    324324                filemap=0;
     
    389389                op, somepath );
    390390
    391         exchange_with_port(logbuffer, size+1, 0);
     391        exchange_with_port(logbuffer, size+1, 0, 0);
    392392       
    393393        return;
     
    472472       
    473473        strcpy(buffer, "dep_check\t");
    474         strcat(buffer, path);
    475         p=exchange_with_port(buffer, strlen(buffer)+1, 1);
     474        strcpy(buffer+10, path);
     475        p=exchange_with_port(buffer, strlen(buffer)+1, 1, 0);
    476476        if((int)p==-1||!p)
    477477                return 0;
     
    487487 * exchange_with_port - routine to send/recv from/to socket
    488488 * Parameters:
    489  *   buf    -- buffer with data to send
    490  *   len    -- length of data
    491  *   answer -- 1 (yes, I want to receive answer) and 0 (no, thanks, just send)
     489 *   buf      -- buffer with data to send
     490 *   len      -- length of data
     491 *   answer   -- 1 (yes, I want to receive answer) and 0 (no, thanks, just send)
     492 *   failures -- should be setted 0 on external calls (avoid infinite recursion)
    492493 * Return value:
    493494 *    -1     -- something went wrong
     
    495496 *    string -- answer (caller shoud free it)
    496497 */
    497 static char * exchange_with_port(const char * buf, size_t len, int answer)
     498static char * exchange_with_port(const char * buf, size_t len, int answer, char failures)
    498499{
    499500        wait_for_socket(__darwintrace_fd, 1);
    500501        if(send(__darwintrace_fd, buf, len, 0)==-1)
     502        {
     503                if(errno==ENOTSOCK && failures<3)
     504                {
     505                        __darwintrace_fd=-1;
     506                        __darwintrace_setup();
     507                        return exchange_with_port(buf, len, answer, failures+1);
     508                }
    501509                return (char*)-1;
     510        }
    502511        if(!answer)
    503512                return 0;
Note: See TracChangeset for help on using the changeset viewer.