MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / write

Method write

common/alog.cpp:227–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225 }
226
227 void write(int, const char* begin, const char* end) override {
228 if (log_file_fd < 0) return;
229 uint64_t length = end - begin;
230 iovec iov{(void*)begin, length};
231#ifndef _WIN64
232 std::ignore = ::writev(log_file_fd, &iov, 1); // writev() is atomic, whereas write() is not
233#else
234 std::ignore = ::write(log_file_fd, iov.iov_base, iov.iov_len);
235#endif
236 throttle_block();
237 if (log_file_name && log_file_size_limit) {
238 log_file_size += length;
239 if (log_file_size > log_file_size_limit) {
240 static mutex log_file_lock;
241 lock_guard<mutex> guard(log_file_lock);
242 if (log_file_size > log_file_size_limit) {
243 log_file_rotate();
244 reopen_log_output_file();
245 }
246 }
247 }
248 }
249
250 static inline void add_generation(char* buf, int size,
251 unsigned int generation) {

Callers

nothing calls this directly

Calls 2

writevFunction · 0.85
writeFunction · 0.85

Tested by

no test coverage detected