MCPcopy Create free account
hub / github.com/acl-dev/acl / uring_write

Function uring_write

lib_fiber/samples-c/benchmark/main.c:66–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64//////////////////////////////////////////////////////////////////////////////
65
66static void uring_write(const char *path)
67{
68 int fd = open(path, __open_flags, 0600), ret;
69 long long i;
70 char buf[1] = { '0' };
71 struct io_uring uring;
72
73 if (fd < 0) {
74 printf("open %s error %s\r\n", path, strerror(errno));
75 exit(1);
76 }
77
78 struct io_uring_params params;
79 memset(&params, 0, sizeof(params));
80
81 ret = io_uring_queue_init_params(100, &uring, &params);
82 if (ret < 0) {
83 printf("init io_uring error=%s\r\n", strerror(errno));
84 exit(1);
85 }
86
87 struct io_uring_sqe *sqe;
88 struct io_uring_cqe *cqe;
89
90 printf("open %s ok, fd=%d\r\n", path, fd);
91
92 for (i = 0; i < __write_count; i++) {
93 sqe = io_uring_get_sqe(&uring);
94 io_uring_prep_write(sqe, fd, buf, 1, i);
95 io_uring_submit(&uring);
96 ret = io_uring_wait_cqes(&uring, &cqe, 1, NULL, NULL);
97 if (ret < 0) {
98 printf("io_uring_wait_cqe error=%s\r\n", strerror(-ret));
99 exit(1);
100 }
101
102 io_uring_cqe_seen(&uring, cqe);
103 }
104
105 ret = write(fd, "\r\n", 2);
106 if (ret <= 0) {
107 printf("write CRLF error %s\r\n", strerror(errno));
108 exit(1);
109 }
110
111 ret = close(fd);
112 printf("close %s %s, fd=%d\r\n", path, ret == 0 ? "ok" : "error", fd);
113 io_uring_queue_exit(&uring);
114}
115
116//////////////////////////////////////////////////////////////////////////////
117

Callers 1

test_writeFunction · 0.85

Calls 3

openFunction · 0.85
writeFunction · 0.50
closeFunction · 0.50

Tested by 1

test_writeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…