Modify

Ticket #5756 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

read_some() with null_buffers blocks in non-blocking mode

Reported by: Gennady Proskurin <gpr@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

I want to poll socket for readability (the same as calling POSIX poll or select with zero timeout), to just know if it is readable:

  1. call sock.non_blocking(true)
  2. call read_some with null_buffers()
  3. it blocks

If I change null_buffers() to some read buffer, all works fine, would_block error is returned. The correct behaviour, I think, is to return immediately with corresponding error (no error if socket is readable, would_block if it is not).

At least tcp socket and posix::stream_descriptor are affected, not tested for other sockets. Also not tested write_some(), not sure if it is affected.

test program attached

Attachments

sd.cc Download (930 bytes) - added by Gennady Proskurin <gpr@…> 3 years ago.

Change History

Changed 3 years ago by Gennady Proskurin <gpr@…>

comment:1 Changed 3 years ago by chris_kohlhoff

(In [74818]) Make sure the synchronous null_buffers operations obey the user's non_blocking setting. Refs #5756

comment:2 Changed 3 years ago by chris_kohlhoff

  • Status changed from new to closed
  • Resolution set to fixed

(In [74863]) Merge from trunk...

Fix compile error in regex overload of async_read_until.hpp. Fixes #5688

Explicitly specify the signal() function from the global namespace. Fixes #5722

Don't read the clock unless the heap is non-empty.

Change the SSL buffers sizes so that they're large enough to hold a complete TLS record. Fixes #5854

Make sure the synchronous null_buffers operations obey the user's non_blocking setting. Fixes #5756

Set size of select fd_set at runtime when using Windows.

Disable warning due to const qualifier being applied to function type.

Fix crash due to gcc_x86_fenced_block that shows up when using the Intel C++ compiler. Fixes #5763

Specialise operations for buffer sequences that are arrays of exactly two buffers.

Initialise all OpenSSL algorithms.

Fix error mapping when session is gracefully shut down.

Various performance improvements:

  • Split the task_io_service's run and poll code.
  • Use thread-local operation queues in single-threaded use cases (i.e. concurrency_hint is 1) to eliminate a lock/unlock pair.
  • Only fence block exit when a handler is being run directly out of the io_service.
  • Prefer x86 mfence-based fenced block when available.
  • Use a plain ol' long for the atomic_count when all thread support is disabled.
  • Allow some epoll_reactor speculative operations to be performed without holding the lock.
  • Improve locality of reference by performing an epoll_reactor's I/O operation immediately before the corresponding handler is called. This also improves scalability across CPUs when multiple threads are running the io_service.
  • Pass same error_code variable through to each operation's complete() function.
  • Optimise creation of and access to the io_service implementation.

Remove unused state in HTTP server examples.

Add latency test programs.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.