Esempio n. 1
0
ssize_t check_request_surprise(ThreadInfo *info) {
  RequestInjectionData &p = info->m_reqInjectionData;
  bool do_timedout, do_memExceeded, do_signaled;

  ssize_t flags = p.fetchAndClearFlags();
  do_timedout = (flags & RequestInjectionData::TimedOutFlag) &&
    !p.getDebugger();
  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 && !pendingException) {
    pendingException = generate_request_timeout_exception();
  }
  if (do_memExceeded && !pendingException) {
    pendingException = generate_memory_exceeded_exception();
  }
  if (do_signaled) f_pcntl_signal_dispatch();

  if (pendingException) {
    pendingException->throwException();
  }
  return flags;
}
Esempio n. 2
0
  Variant execute() {
    ASSERT(!m_exception);
    if (m_cp == NULL) {
      return false;
    }
    if (m_emptyPost) {
      // As per curl docs, an empty post must set POSTFIELDSIZE to be 0 or
      // the reader function will be called
      curl_easy_setopt(m_cp, CURLOPT_POSTFIELDSIZE, 0);
    }
    m_write.buf.reset();
    m_write.content.clear();
    m_header.clear();
    memset(m_error_str, 0, sizeof(m_error_str));

    {
      IOStatusHelper io("curl_easy_perform", m_url.data());
      SYNC_VM_REGS_SCOPED();
      m_error_no = curl_easy_perform(m_cp);
      if (m_exception) {
        if (m_phpException) {
          Object e((ObjectData*)m_exception);
          m_exception = NULL;
          e.get()->decRefCount();
          throw e;
        } else {
          Exception *e = (Exception*)m_exception;
          m_exception = NULL;
          e->throwException();
        }
      }
    }
    set_curl_statuses(m_cp, m_url.data());

    /* CURLE_PARTIAL_FILE is returned by HEAD requests */
    if (m_error_no != CURLE_OK && m_error_no != CURLE_PARTIAL_FILE) {
      m_write.buf.reset();
      m_write.content.clear();
      return false;
    }

    if (m_write.method == PHP_CURL_RETURN) {
      if (!m_write.buf.empty()) {
        m_write.content = m_write.buf.detach();
      }
      if (!m_write.content.empty()) {
        return m_write.content;
      }
    }
    if (m_write.method == PHP_CURL_RETURN) {
      return String("");
    }
    return true;
  }
Esempio n. 3
0
 void check_exception() {
   if (m_exception) {
     if (m_phpException) {
       Object e((ObjectData*)m_exception);
       m_exception = NULL;
       e.get()->decRefCount();
       throw e;
     } else {
       Exception *e = (Exception*)m_exception;
       m_exception = NULL;
       e->throwException();
     }
   }
 }