Example #1
0
void HttpRequest::close() {
  // std::cerr << "Closing handle " << &_handle << std::endl;
  if (_protocol == WebSockets)
    _pWebApplication->onWSClose(_pWebSocketConnection);
  _pSocket->removeConnection(this);
  uv_close(toHandle(&_handle.stream), HttpRequest_on_closed);
}
Example #2
0
void Socket::destroy() {
  for (std::vector<HttpRequest*>::reverse_iterator it = connections.rbegin();
    it != connections.rend();
    it++) {

    // std::cerr << "Request close on " << *it << std::endl;
    (*it)->close();
  }
  uv_close(toHandle(&handle.stream), on_Socket_close);
}
Example #3
0
int32_t
omrfile_close(struct OMRPortLibrary *portLibrary, intptr_t fd)
{
	HANDLE handle = toHandle(portLibrary, fd);

	Trc_PRT_file_close_Entry(fd);

	if ((intptr_t) INVALID_HANDLE_VALUE == fd) {
		/* RTC 100203 Windows 10 does not report an error when closing an invalid handle */
		portLibrary->error_set_last_error(portLibrary, 0, OMRPORT_ERROR_FILE_INVALID_PARAMETER);
		Trc_PRT_file_close_invalidFileHandle();
		return -1;
	} else if (TRUE == CloseHandle(handle)) {
		Trc_PRT_file_close_Exit(0);
		return 0;
	} else {
		int32_t error = GetLastError();
		error = portLibrary->error_set_last_error(portLibrary, error, findError(error));
		Trc_PRT_file_close_ExitFail(error);
		return -1;
	}
}
Example #4
0
int32_t
omrfile_sync(struct OMRPortLibrary *portLibrary, intptr_t fd)
{
	HANDLE handle = toHandle(portLibrary, fd);

	Trc_PRT_file_sync_Entry(fd);

	/*
	 * According to MSDN:
	 * 1) If hFile is a handle to the server end of a named pipe, the function does not return until the client has read all buffered data from the pipe.
	 * 2) The function fails if hFile is a handle to the console output. That is because the console output is not buffered. The function returns FALSE, and GetLastError returns ERROR_INVALID_HANDLE.
	 *
	 * This behaviour caused JAZZ 44899 defect: Test_SimpleTenantLimitXmt would freeze while waiting for process to terminate while child
	 * was waiting for parent to read from STDIN and STDOUT streams of a child.
	 *
	 * Manual testing showed that even if we called System.out.print('X') and System.err.print('Y') a parent process would still get receive 'X' and 'Y'
	 * (with and without flushing) after child process in terminated.
	 *
	 * This check does not modify original behaviour of the port library because we never actually flushed STDIN and STDOUT handles but
	 * some arbitrary handles 1 & 2.
	 */
	if (((HANDLE)OMRPORT_TTY_OUT == (HANDLE)fd) || ((HANDLE)OMRPORT_TTY_ERR == (HANDLE)fd)) {
		Trc_PRT_file_sync_Exit(0);
		return 0;
	}

	if (FlushFileBuffers(handle)) {
		Trc_PRT_file_sync_Exit(0);
		return 0;
	} else {
		int32_t error = GetLastError();
		error = portLibrary->error_set_last_error(portLibrary, error, findError(error));
		Trc_PRT_file_sync_Exit(error);
		return -1;
	}
}
Example #5
0
intptr_t
omrfile_convert_omrfile_fd_to_native_fd(struct OMRPortLibrary *portLibrary, intptr_t omrfileFD)
{
	return (intptr_t) toHandle(portLibrary, omrfileFD);
}