From owner-freebsd-hackers@FreeBSD.ORG Thu May 13 15:01:22 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A8A351065677 for ; Thu, 13 May 2010 15:01:22 +0000 (UTC) (envelope-from krivenok.dmitry@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by mx1.freebsd.org (Postfix) with ESMTP id 3C3F18FC0A for ; Thu, 13 May 2010 15:01:21 +0000 (UTC) Received: by ey-out-2122.google.com with SMTP id d26so160577eyd.9 for ; Thu, 13 May 2010 08:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=Neg0i+wV7XVrITeHU5MEu9rYkFc1MBrOjMQD737WwJA=; b=aZkjd06tQ849spgdhP1//kr67P4i7sGrN93/0AzhcJYPW5gl8UMzT2sAo2h7aQWXRA 0MKRQxMp9HquO8EEBFREathbBlPLbxtvzYQmj3GfP1nqemVJilBiyCdEtev/2JR0/0eX RVASTZR3tWdYsx3GjsW3shLZb6qo4Fevvpnpg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=cNNWhSSWQNebmjGTTXa0DRSZ4x7DoOkrkp029euFCUwsAw3Nrr3jmPXldokCdgy3IP 67vFFriXZ9Z+hkw4U2TLDSdtv4uun5TexFs9+H8o2LmrLZc5LdIqkbUfWCT380m7cGoa 4qLm81Mj1kEd4opSsNOBsqahA4KFF9jXxihs8= MIME-Version: 1.0 Received: by 10.213.55.13 with SMTP id s13mr1465492ebg.34.1273762881174; Thu, 13 May 2010 08:01:21 -0700 (PDT) Received: by 10.213.35.197 with HTTP; Thu, 13 May 2010 08:01:20 -0700 (PDT) Date: Thu, 13 May 2010 19:01:20 +0400 Message-ID: From: Dmitry Krivenok To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Need advice about selsocket analogue for a set of sockets X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2010 15:01:22 -0000 Hi Hackers, I know that FreeBSD-8 kernel provides selsocket function declared as follows: int selsocket(struct socket *so, int events, struct timeval *tvp, struct thread *td); It's very useful if you have just one socket and don't care about which events fired. In my case, however, I have an array of the following structures typedef struct { struct socket *fd; int events; int revents; } sock_poll_t; and need to poll all sockets saving results in revents field. That is I need to implement a function with the following prototype: int sockets_poll( sock_poll_t * ufds, unsigned int nfds, int timeout_msecs); Obviously, selsocket is useless is such scenario (it returns 0 on success and therefore doesn't tell which events fired). I looked into sys/kern/sys_generic.c but didn't find any functions which may be useful for working with array of structures above. I could try to implement a function similar to selsocket, but I cannot use the same helper functions (selfdalloc, seltdwait, etc) because they are considered as implementation details and defined as static. I need your advice. What's the best way of solving my problem? Thanks in advance! -- Sincerely yours, Dmitry V. Krivenok e-mail: krivenok.dmitry@gmail.com skype: krivenok_dmitry jabber: krivenok_dmitry@jabber.ru icq: 242-526-443