Example #1
0
ssize_t check_request_surprise(ThreadInfo* info) {
  auto& p = info->m_reqInjectionData;
  bool do_timedout, do_memExceeded, do_signaled;

  ssize_t flags = p.fetchAndClearFlags();
  do_timedout = (flags & RequestInjectionData::TimedOutFlag) &&
    !p.getDebuggerAttached();
  do_memExceeded = (flags & RequestInjectionData::MemExceededFlag);
  do_signaled = (flags & RequestInjectionData::SignaledFlag);

  // Start with any pending exception that might be on the thread.
  Exception* pendingException = info->m_pendingException;
  info->m_pendingException = nullptr;

  if (do_timedout) {
    if (pendingException) {
      p.setTimedOutFlag();
    } else {
      pendingException = generate_request_timeout_exception();
    }
  }
  if (do_memExceeded) {
    if (pendingException) {
      p.setMemExceededFlag();
    } else {
      pendingException = generate_memory_exceeded_exception();
    }
  }
  if (do_signaled) {
    extern bool f_pcntl_signal_dispatch();
    f_pcntl_signal_dispatch();
  }

  if (pendingException) {
    pendingException->throwException();
  }
  return flags;
}
bool TestExtProcess::test_pcntl_signal_dispatch() {
  f_pcntl_signal_dispatch();
  return Count(true);
}