Changeset 3748


Ignore:
Timestamp:
Mar 4, 2012, 7:51:21 PM (13 years ago)
Author:
bird
Message:

trunk: forward ported r3745, r3746 and r3747 - high memory regression in libsocket and a fix for high memory and socketpair(). References #233.

Location:
trunk/libc/src/libsocket
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/libsocket/getpeername.c

    r3674 r3748  
    5454        }
    5555    }
    56     LIBCLOG_RETURN_INT(-1);
     56    LIBCLOG_RETURN_INT(rc);
    5757}
    5858
  • trunk/libc/src/libsocket/highmemsocket.c

    r3674 r3748  
    116116        return 0;
    117117
    118     if (__libsocket_safe_copy(&pSafeAddr->cbAddr, pcbAddr, sizeof(*pcbAddr)) != 0)
     118    if (__libsocket_safe_copy(&pSafeAddr->cbAddr, pcbAddr, sizeof(*pcbAddr)) == 0)
    119119    {
    120120        pSafeAddr->cbAlloc = pSafeAddr->cbAddr;
     
    122122        if (pSafeAddr->pvFree)
    123123        {
    124             if (__libsocket_safe_copy(pSafeAddr->pvFree, pAddr, pSafeAddr->cbAlloc) != 0)
     124            if (__libsocket_safe_copy(pSafeAddr->pvFree, pAddr, pSafeAddr->cbAlloc) == 0)
    125125            {
    126126                pSafeAddr->pAddr   = (struct sockaddr *)pSafeAddr->pvFree;
  • trunk/libc/src/libsocket/socketpair.c

    r3630 r3748  
    126126    int             fh1;
    127127    int             fh2;
     128    int             aNativeFDs[2] = {-1, -1};
    128129    PLIBCSOCKETFH   pFH1;
    129130
    130     rc = __libsocket_socketpair(af, type, flags, osfd);
     131    /* Make sure we crash here if parameter is invalid. */
     132    osfd[0] = -1;
     133    osfd[1] = -1;
     134
     135    /* Call the native API. */
     136    rc = __libsocket_socketpair(af, type, flags, aNativeFDs);
    131137    if (rc < 0)
    132138    {
     
    138144     * Allocate LIBC sockets.
    139145     */
    140     pFH1 = TCPNAMEG(AllocFH)(osfd[0], &fh1);
     146    pFH1 = TCPNAMEG(AllocFH)(aNativeFDs[0], &fh1);
    141147    if (pFH1)
    142148    {
    143         PLIBCSOCKETFH   pFH2 = TCPNAMEG(AllocFH)(osfd[1], &fh2);
     149        PLIBCSOCKETFH   pFH2 = TCPNAMEG(AllocFH)(aNativeFDs[1], &fh2);
    144150        if (pFH2)
    145151        {
     
    149155            LIBCLOG_RETURN_MSG(0, "ret 0 osfd[0]=%d osfd[1]=%d\n", osfd[0], osfd[1]);
    150156        }
    151         __libsocket_soclose(osfd[1]);
     157         
     158        __libsocket_soclose(aNativeFDs[1]);
    152159        __libc_Back_ioClose(fh1);
    153160    }
    154161    else
    155162    {
    156         __libsocket_soclose(osfd[1]);
    157         __libsocket_soclose(osfd[0]);
     163        __libsocket_soclose(aNativeFDs[1]);
     164        __libsocket_soclose(aNativeFDs[0]);
    158165    }
    159166
Note: See TracChangeset for help on using the changeset viewer.