)]}'
{
  "commit": "aaca0bdca573f3f51ea03139f9c7289541e7bca3",
  "tree": "d25b0baa73b5301d91a5c848a896bad0fb719acc",
  "parents": [
    "a677a039be7243357d93502bff2b40850c942e2d"
  ],
  "author": {
    "name": "Ulrich Drepper",
    "email": "drepper@redhat.com",
    "time": "Wed Jul 23 21:29:20 2008 -0700"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Thu Jul 24 10:47:27 2008 -0700"
  },
  "message": "flag parameters: paccept\n\nThis patch is by far the most complex in the series.  It adds a new syscall\npaccept.  This syscall differs from accept in that it adds (at the userlevel)\ntwo additional parameters:\n\n- a signal mask\n- a flags value\n\nThe flags parameter can be used to set flag like SOCK_CLOEXEC.  This is\nimlpemented here as well.  Some people argued that this is a property which\nshould be inherited from the file desriptor for the server but this is against\nPOSIX.  Additionally, we really want the signal mask parameter as well\n(similar to pselect, ppoll, etc).  So an interface change in inevitable.\n\nThe flag value is the same as for socket and socketpair.  I think diverging\nhere will only create confusion.  Similar to the filesystem interfaces where\nthe use of the O_* constants differs, it is acceptable here.\n\nThe signal mask is handled as for pselect etc.  The mask is temporarily\ninstalled for the thread and removed before the call returns.  I modeled the\ncode after pselect.  If there is a problem it\u0027s likely also in pselect.\n\nFor architectures which use socketcall I maintained this interface instead of\nadding a system call.  The symmetry shouldn\u0027t be broken.\n\nThe following test must be adjusted for architectures other than x86 and\nx86-64 and in case the syscall numbers changed.\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n#include \u003cerrno.h\u003e\n#include \u003cfcntl.h\u003e\n#include \u003cpthread.h\u003e\n#include \u003csignal.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cunistd.h\u003e\n#include \u003cnetinet/in.h\u003e\n#include \u003csys/socket.h\u003e\n#include \u003csys/syscall.h\u003e\n\n#ifndef __NR_paccept\n# ifdef __x86_64__\n#  define __NR_paccept 288\n# elif defined __i386__\n#  define SYS_PACCEPT 18\n#  define USE_SOCKETCALL 1\n# else\n#  error \"need __NR_paccept\"\n# endif\n#endif\n\n#ifdef USE_SOCKETCALL\n# define paccept(fd, addr, addrlen, mask, flags) \\\n  ({ long args[6] \u003d { \\\n       (long) fd, (long) addr, (long) addrlen, (long) mask, 8, (long) flags }; \\\n     syscall (__NR_socketcall, SYS_PACCEPT, args); })\n#else\n# define paccept(fd, addr, addrlen, mask, flags) \\\n  syscall (__NR_paccept, fd, addr, addrlen, mask, 8, flags)\n#endif\n\n#define PORT 57392\n\n#define SOCK_CLOEXEC O_CLOEXEC\n\nstatic pthread_barrier_t b;\n\nstatic void *\ntf (void *arg)\n{\n  pthread_barrier_wait (\u0026b);\n  int s \u003d socket (AF_INET, SOCK_STREAM, 0);\n  struct sockaddr_in sin;\n  sin.sin_family \u003d AF_INET;\n  sin.sin_addr.s_addr \u003d htonl (INADDR_LOOPBACK);\n  sin.sin_port \u003d htons (PORT);\n  connect (s, (const struct sockaddr *) \u0026sin, sizeof (sin));\n  close (s);\n\n  pthread_barrier_wait (\u0026b);\n  s \u003d socket (AF_INET, SOCK_STREAM, 0);\n  sin.sin_port \u003d htons (PORT);\n  connect (s, (const struct sockaddr *) \u0026sin, sizeof (sin));\n  close (s);\n  pthread_barrier_wait (\u0026b);\n\n  pthread_barrier_wait (\u0026b);\n  sleep (2);\n  pthread_kill ((pthread_t) arg, SIGUSR1);\n\n  return NULL;\n}\n\nstatic void\nhandler (int s)\n{\n}\n\nint\nmain (void)\n{\n  pthread_barrier_init (\u0026b, NULL, 2);\n\n  struct sockaddr_in sin;\n  pthread_t th;\n  if (pthread_create (\u0026th, NULL, tf, (void *) pthread_self ()) !\u003d 0)\n    {\n      puts (\"pthread_create failed\");\n      return 1;\n    }\n\n  int s \u003d socket (AF_INET, SOCK_STREAM, 0);\n  int reuse \u003d 1;\n  setsockopt (s, SOL_SOCKET, SO_REUSEADDR, \u0026reuse, sizeof (reuse));\n  sin.sin_family \u003d AF_INET;\n  sin.sin_addr.s_addr \u003d htonl (INADDR_LOOPBACK);\n  sin.sin_port \u003d htons (PORT);\n  bind (s, (struct sockaddr *) \u0026sin, sizeof (sin));\n  listen (s, SOMAXCONN);\n\n  pthread_barrier_wait (\u0026b);\n\n  int s2 \u003d paccept (s, NULL, 0, NULL, 0);\n  if (s2 \u003c 0)\n    {\n      puts (\"paccept(0) failed\");\n      return 1;\n    }\n\n  int coe \u003d fcntl (s2, F_GETFD);\n  if (coe \u0026 FD_CLOEXEC)\n    {\n      puts (\"paccept(0) set close-on-exec-flag\");\n      return 1;\n    }\n  close (s2);\n\n  pthread_barrier_wait (\u0026b);\n\n  s2 \u003d paccept (s, NULL, 0, NULL, SOCK_CLOEXEC);\n  if (s2 \u003c 0)\n    {\n      puts (\"paccept(SOCK_CLOEXEC) failed\");\n      return 1;\n    }\n\n  coe \u003d fcntl (s2, F_GETFD);\n  if ((coe \u0026 FD_CLOEXEC) \u003d\u003d 0)\n    {\n      puts (\"paccept(SOCK_CLOEXEC) does not set close-on-exec flag\");\n      return 1;\n    }\n  close (s2);\n\n  pthread_barrier_wait (\u0026b);\n\n  struct sigaction sa;\n  sa.sa_handler \u003d handler;\n  sa.sa_flags \u003d 0;\n  sigemptyset (\u0026sa.sa_mask);\n  sigaction (SIGUSR1, \u0026sa, NULL);\n\n  sigset_t ss;\n  pthread_sigmask (SIG_SETMASK, NULL, \u0026ss);\n  sigaddset (\u0026ss, SIGUSR1);\n  pthread_sigmask (SIG_SETMASK, \u0026ss, NULL);\n\n  sigdelset (\u0026ss, SIGUSR1);\n  alarm (4);\n  pthread_barrier_wait (\u0026b);\n\n  errno \u003d 0 ;\n  s2 \u003d paccept (s, NULL, 0, \u0026ss, 0);\n  if (s2 !\u003d -1 || errno !\u003d EINTR)\n    {\n      puts (\"paccept did not fail with EINTR\");\n      return 1;\n    }\n\n  close (s);\n\n  puts (\"OK\");\n\n  return 0;\n}\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n[akpm@linux-foundation.org: make it compile]\n[akpm@linux-foundation.org: add sys_ni stub]\nSigned-off-by: Ulrich Drepper \u003cdrepper@redhat.com\u003e\nAcked-by: Davide Libenzi \u003cdavidel@xmailserver.org\u003e\nCc: Michael Kerrisk \u003cmtk.manpages@googlemail.com\u003e\nCc: \u003clinux-arch@vger.kernel.org\u003e\nCc: \"David S. Miller\" \u003cdavem@davemloft.net\u003e\nCc: Roland McGrath \u003croland@redhat.com\u003e\nCc: Kyle McMartin \u003ckyle@mcmartin.ca\u003e\nSigned-off-by: Andrew Morton \u003cakpm@linux-foundation.org\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "08c9793199290fefc36f027da65f7e7e50f9cd43",
      "old_mode": 33188,
      "old_path": "include/asm-alpha/socket.h",
      "new_id": "a1057c2d95e7047e06ab1c9df73392b9f49e8ab6",
      "new_mode": 33188,
      "new_path": "include/asm-alpha/socket.h"
    },
    {
      "type": "modify",
      "old_id": "69a7a0d30b025335f927979f1eb14e7750d3c09a",
      "old_mode": 33188,
      "old_path": "include/asm-parisc/socket.h",
      "new_id": "fba402c95ac2d403856e141508453646c3a38b5e",
      "new_mode": 33188,
      "new_path": "include/asm-parisc/socket.h"
    },
    {
      "type": "modify",
      "old_id": "9c1a4a3470d96441d4bd194d12ff5541b321d135",
      "old_mode": 33188,
      "old_path": "include/asm-x86/unistd_64.h",
      "new_id": "e323994a370ff4e1282d41745466e4de60e8c7c3",
      "new_mode": 33188,
      "new_path": "include/asm-x86/unistd_64.h"
    },
    {
      "type": "modify",
      "old_id": "8b5383c45b456ec2f5cf4e142d4b20c1c9a563b2",
      "old_mode": 33188,
      "old_path": "include/linux/net.h",
      "new_id": "3a9b06d4d0fe5d0f2acf265b83f93b70f8eca419",
      "new_mode": 33188,
      "new_path": "include/linux/net.h"
    },
    {
      "type": "modify",
      "old_id": "4394dadff813b014ded5651ebdd06c1c97fddb5e",
      "old_mode": 33188,
      "old_path": "include/linux/syscalls.h",
      "new_id": "2a2a40af6b2c9b252fe3986bde43ee4a98a94472",
      "new_mode": 33188,
      "new_path": "include/linux/syscalls.h"
    },
    {
      "type": "modify",
      "old_id": "0fea0ee12da96875bca1833e0bdf1c07163531d4",
      "old_mode": 33188,
      "old_path": "kernel/sys_ni.c",
      "new_id": "2f0b8a2e600f189d3516c5524123cbc6f2cb53d2",
      "new_mode": 33188,
      "new_path": "kernel/sys_ni.c"
    },
    {
      "type": "modify",
      "old_id": "6e1b03b51933cf897fc7c24cf1fa4d561b0e6243",
      "old_mode": 33188,
      "old_path": "net/compat.c",
      "new_id": "67fb6a3834a3a538221b347c309842cda1816521",
      "new_mode": 33188,
      "new_path": "net/compat.c"
    },
    {
      "type": "modify",
      "old_id": "64601f900352ff90d9ccea0f0c9b436aa656b840",
      "old_mode": 33188,
      "old_path": "net/socket.c",
      "new_id": "a0ce8ad722524b8290ffc6f046e66c9ab2365728",
      "new_mode": 33188,
      "new_path": "net/socket.c"
    }
  ]
}
