Date: Fri, 11 May 2007 18:34:02 GMT From: Fredrik Lindberg <fli@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 119683 for review Message-ID: <200705111834.l4BIY2ON013458@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119683 Change 119683 by fli@fli_genesis on 2007/05/11 18:33:21 o Check if we actually managed to allocate a buffer o Make mdns_tcp_recv return bytes read (as mdns_udp_recv does) o Remove false unused attribute o mdns_tcp_client have to return the new socket, not 0 Affected files ... .. //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_mdns.c#3 edit Differences ... ==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/stack_mdns.c#3 (text+ko) ==== @@ -730,13 +730,14 @@ return (-1); } - pkg = pc->pc_pkg; + pkg = pc->pc_pkg != NULL ? pc->pc_pkg : pkg_alloc(pc); if (pkg == NULL) - pkg = pkg_alloc(pc); + return (-1); - buf = MDNS_BUFH(&pkg->p_buflist); + buf = MDNS_BUFH(&pkg->p_buflist) != NULL ? MDNS_BUFH(&pkg->p_buflist) : + mdns_buf_alloc(md->md_bp, &pkg->p_buflist, 0, 0); if (buf == NULL) - buf = mdns_buf_alloc(md->md_bp, &pkg->p_buflist, 0, 1); + return (-1); iov[0].iov_base = MDNS_BUF(buf); iov[0].iov_len = MDNS_BUFSZ(buf); @@ -780,7 +781,7 @@ if (nsock < 0) return (-1); fcntl(nsock, F_SETFL, O_NONBLOCK); - return (0); + return (nsock); } /* @@ -847,8 +848,7 @@ * pc - Destination packet chain */ int -mdns_tcp_recv(__attribute__((unused)) struct mdns *md, int sock, - struct mdns_pkgchain *pc) +mdns_tcp_recv(struct mdns *md, int sock, struct mdns_pkgchain *pc) { struct mdns_packet *pkg; struct mdns_buf *buf; @@ -857,13 +857,14 @@ MDNS_INIT_ASSERT(md, md_magic); MDNS_INIT_ASSERT(pc, pc_magic); - pkg = pc->pc_pkg; + pkg = pc->pc_pkg != NULL ? pc->pc_pkg : pkg_alloc(pc); if (pkg == NULL) - pkg = pkg_alloc(pc); + return (-1); - buf = MDNS_BUFH(&pkg->p_buflist); + buf = MDNS_BUFH(&pkg->p_buflist) != NULL ? MDNS_BUFH(&pkg->p_buflist) : + mdns_buf_alloc(md->md_bp, &pkg->p_buflist, 0, 0); if (buf == NULL) - buf = mdns_buf_alloc(md->md_bp, &pkg->p_buflist, 0, 1); + return (-1); for (;;) { n = read(sock, MDNS_BUF(buf), MDNS_BUFSZ(buf)); @@ -873,7 +874,9 @@ } if ((unsigned int)n < MDNS_BUFSZ(buf)) break; - buf = mdns_buf_alloc(md->md_bp, &pkg->p_buflist, 0, 1); + buf = mdns_buf_alloc(md->md_bp, &pkg->p_buflist, 0, 0); + if (buf == NULL) + return (-1); } /* @@ -883,8 +886,10 @@ * with legacy clients. */ buf = mdns_buf_merge(md->md_bp, &pkg->p_buflist, 1); + if (buf == NULL) + return (-1); - return (0); + return (pkg->p_len); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705111834.l4BIY2ON013458>