1. 18 4月, 2011 5 次提交
    • R
      debloat: use __syscall instead of syscall where possible · eb0e8fa0
      Rich Felker 提交于
      don't waste time (and significant code size due to function call
      overhead!) setting errno when the result of a syscall does not matter
      or when it can't fail.
      eb0e8fa0
    • R
      fix bugs in cancellable syscall asm · 09dae2b7
      Rich Felker 提交于
      x86_64 was just plain wrong in the cancel-flag-already-set path, and
      crashing.
      
      the more subtle error was not clearing the saved stack pointer before
      returning to c code. this could result in the signal handler
      misidentifying c code as the pre-syscall part of the asm, and acting
      on cancellation at the wrong time, and thus resource leak race
      conditions.
      
      also, now __cancel (in the c code) is responsible for clearing the
      saved sp in the already-cancelled branch. this means we have to use
      call rather than jmp to ensure the stack pointer in the c will never
      match what the asm saved.
      09dae2b7
    • R
      optimize cancellation enable/disable code · ebf82447
      Rich Felker 提交于
      the goal is to be able to use pthread_setcancelstate internally in
      the implementation, whenever a function might want to use functions
      which are cancellation points but avoid becoming a cancellation point
      itself. i could have just used a separate internal function for
      temporarily inhibiting cancellation, but the solution in this commit
      is better because (1) it's one less implementation-specific detail in
      functions that need to use it, and (2) application code can also get
      the same benefit.
      
      previously, pthread_setcancelstate dependend on pthread_self, which
      would pull in unwanted thread setup overhead for non-threaded
      programs. now, it temporarily stores the state in the global libc
      struct if threads have not been initialized, and later moves it if
      needed. this way we can instead use __pthread_self, which has no
      dependencies and assumes that the thread register is already valid.
      ebf82447
    • R
      02eff258
    • R
      fix some minor issues in cancellation handling patch · e7466401
      Rich Felker 提交于
      signals were wrongly left masked, and cancellability state was not
      switched to disabled, during the execution of cleanup handlers.
      e7466401
  2. 17 4月, 2011 1 次提交
    • R
      overhaul pthread cancellation · feee9890
      Rich Felker 提交于
      this patch improves the correctness, simplicity, and size of
      cancellation-related code. modulo any small errors, it should now be
      completely conformant, safe, and resource-leak free.
      
      the notion of entering and exiting cancellation-point context has been
      completely eliminated and replaced with alternative syscall assembly
      code for cancellable syscalls. the assembly is responsible for setting
      up execution context information (stack pointer and address of the
      syscall instruction) which the cancellation signal handler can use to
      determine whether the interrupted code was in a cancellable state.
      
      these changes eliminate race conditions in the previous generation of
      cancellation handling code (whereby a cancellation request received
      just prior to the syscall would not be processed, leaving the syscall
      to block, potentially indefinitely), and remedy an issue where
      non-cancellable syscalls made from signal handlers became cancellable
      if the signal handler interrupted a cancellation point.
      
      x86_64 asm is untested and may need a second try to get it right.
      feee9890
  3. 16 4月, 2011 3 次提交
  4. 15 4月, 2011 4 次提交
  5. 14 4月, 2011 7 次提交
    • R
      simplify cancellation point handling · 9beb6330
      Rich Felker 提交于
      we take advantage of the fact that unless self->cancelpt is 1,
      cancellation cannot happen. so just increment it by 2 to temporarily
      block cancellation. this drops pthread_create.o well under 1k.
      9beb6330
    • R
      simplify syslog, add vsyslog interface (nonstandard) · 19c1830e
      Rich Felker 提交于
      with datagram sockets, depending on fprintf not to flush the output
      early was very fragile; the new version simply uses a small fixed-size
      buffer. it could be updated to dynamic-allocate large buffers if
      needed, but i can't envision any admin being happy about finding
      64kb-long lines in their syslog...
      19c1830e
    • R
      remove useless SIGPIPE protection from syslog · a77411a5
      Rich Felker 提交于
      per the standard, SIGPIPE is not generated for SOCK_DGRAM.
      a77411a5
    • R
      fix syslog (corrected SIGPIPE blocking, and using dgram instead of stream) · a444ee34
      Rich Felker 提交于
      it actually appears the hacks to block SIGPIPE are probably not
      necessary, and potentially harmful. if i can confirm this, i'll remove
      them.
      a444ee34
    • R
      numerous fixes to sysv ipc · 07e865cc
      Rich Felker 提交于
      some of these definitions were just plain wrong, others based on
      outdated ancient "non-64" versions of the kernel interface.
      
      as much as possible has now been moved out of bits/*
      
      these changes break abi (the old abi for these functions was wrong),
      but since they were not working anyway it can hardly matter.
      07e865cc
    • R
      add syscall wrapper for flock · 55b123b5
      Rich Felker 提交于
      it should be noted that flock does not mix well with standard fcntl
      locking, but nonetheless some applications will attempt to use flock
      instead of fcntl if both exist. options to configure or small patches
      may be needed. debian maintainers have plenty of experience with this
      unfortunate situation...
      55b123b5
    • R
  6. 13 4月, 2011 8 次提交
  7. 12 4月, 2011 1 次提交
  8. 11 4月, 2011 3 次提交
  9. 09 4月, 2011 5 次提交
    • R
      2063c4ca
    • R
      greatly improve SIGEV_THREAD timers · 82171d6a
      Rich Felker 提交于
      calling pthread_exit from, or pthread_cancel on, the timer callback
      thread will no longer destroy the timer.
      82171d6a
    • R
      work around a nasty bug in linux readv syscall · 2cff36a8
      Rich Felker 提交于
      according to posix, readv "shall be equivalent to read(), except..."
      that it places the data into the buffers specified by the iov array.
      however on linux, when reading from a terminal, each iov element
      behaves almost like a separate read. this means that if the first iov
      exactly satisfied the request (e.g. a length-one read of '\n') and the
      second iov is nonzero length, the syscall will block again after
      getting the blank line from the terminal until another line is read.
      simply put, entering a single blank line becomes impossible.
      
      the solution, fortunately, is simple. whenever the buffer size is
      nonzero, reduce the length of the requested read by one byte and let
      the last byte go through the buffer. this way, readv will already be
      in the second (and last) iov, and won't re-block on the second iov.
      2cff36a8
    • R
      better fix sysconf pthread stack min · 67e793e5
      Rich Felker 提交于
      67e793e5
    • R
      consistency with pthread stack min in limits.h · 5e72cb4a
      Rich Felker 提交于
      5e72cb4a
  10. 08 4月, 2011 3 次提交