rem: sock = get_send_socket(0, &to, PROTO_UDP); if (sock == NULL) { LOG(L_ERR, "error: mediaproxy/pingClients(): can't get sending socket\n"); continue;
add: if (sock==0) { sock = get_send_socket(0, &to, PROTO_UDP); if (sock == NULL) { LOG(L_ERR, "error: mediaproxy/pingClients(): can't get " "sending socket\n"); continue; }
context: pingClients(unsigned int ticks, void *param){    static char pingbuf[4] = "\0\0\0\0";    static int length = 256;    struct socket_info* sock;    struct hostent* hostent;    union sockaddr_union to;    struct sip_uri uri;    void *buf, *ptr;    str contact;    int needed;    buf = pkg_malloc(length);    if (buf == NULL) {        LOG(L_ERR, "error: mediaproxy/pingClients(): out of memory\n");        return;    }    needed = userLocation.get_all_ucontacts(buf, length, FL_NAT);    if (needed > 0) {        // make sure we alloc more than actually we were told is missing        // (some clients may register while we are making these calls)        length = (length + needed) * 2;        ptr = pkg_realloc(buf, length);        if (ptr == NULL) {            LOG(L_ERR, "error: mediaproxy/pingClients(): out of memory\n");            pkg_free(buf);            return;        } else {            buf = ptr;        }        // try again. we may fail again if _many_ clients register in between        needed = userLocation.get_all_ucontacts(buf, length, FL_NAT);        if (needed != 0) {            pkg_free(buf);            return;        }    }    ptr = buf;    while (1) {        memcpy(&(contact.len), ptr, sizeof(contact.len));        if (contact.len == 0)            break;        contact.s = (char*)ptr + sizeof(contact.len);        ptr = contact.s + contact.len;        if (parse_uri(contact.s, contact.len, &uri) < 0) {            LOG(L_ERR, "error: mediaproxy/pingClients(): can't parse contact uri\n");            continue;        }        if (uri.proto != PROTO_UDP && uri.proto != PROTO_NONE)            continue;        if (uri.port_no == 0)            uri.port_no = SIP_PORT;        hostent = sip_resolvehost(&uri.host, &uri.port_no, PROTO_UDP);        if (hostent == NULL){            LOG(L_ERR, "error: mediaproxy/pingClients(): can't resolve host\n");            continue;        }        hostent2su(&to, hostent, 0, uri.port_no);        sock = get_send_socket(0, &to, PROTO_UDP);        if (sock == NULL) {            LOG(L_ERR, "error: mediaproxy/pingClients(): can't get sending socket\n");            continue;        }        udp_send(sock, pingbuf, sizeof(pingbuf), &to);    }    pkg_free(buf);}