2019-08-17 20:33:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/WriteBufferFromFileDescriptor.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Write to file descriptor but drop the data if write would block or fail.
|
|
|
|
* To use within signal handler. Motivating example: a signal handler invoked during execution of malloc
|
|
|
|
* should not block because some mutex (or even worse - a spinlock) may be held.
|
|
|
|
*/
|
|
|
|
class WriteBufferFromFileDescriptorDiscardOnFailure : public WriteBufferFromFileDescriptor
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
void nextImpl() override;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor;
|
2022-03-13 11:59:20 +00:00
|
|
|
~WriteBufferFromFileDescriptorDiscardOnFailure() override = default;
|
2019-08-17 20:33:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|