MCPcopy Index your code
hub / github.com/git/git / app__sendbytes_command

Function app__sendbytes_command

t/helper/test-simple-ipc.c:116–155  ·  view source on GitHub ↗

* The client sent a command followed by a (possibly very) large buffer. */

Source from the content-addressed store, hash-verified

114 * The client sent a command followed by a (possibly very) large buffer.
115 */
116static int app__sendbytes_command(const char *received, size_t received_len,
117 ipc_server_reply_cb *reply_cb,
118 struct ipc_server_reply_data *reply_data)
119{
120 struct strbuf buf_resp = STRBUF_INIT;
121 const char *p = "?";
122 int len_ballast = 0;
123 int k;
124 int errs = 0;
125 int ret;
126
127 /*
128 * The test is setup to send:
129 * "sendbytes" SP <n * char>
130 */
131 if (received_len < strlen("sendbytes "))
132 BUG("received_len is short in app__sendbytes_command");
133
134 if (skip_prefix(received, "sendbytes ", &p))
135 len_ballast = strlen(p);
136
137 /*
138 * Verify that the ballast is n copies of a single letter.
139 * And that the multi-threaded IO layer didn't cross the streams.
140 */
141 for (k = 1; k < len_ballast; k++)
142 if (p[k] != p[0])
143 errs++;
144
145 if (errs)
146 strbuf_addf(&buf_resp, "errs:%d\n", errs);
147 else
148 strbuf_addf(&buf_resp, "rcvd:%c%08d\n", p[0], len_ballast);
149
150 ret = reply_cb(reply_data, buf_resp.buf, buf_resp.len);
151
152 strbuf_release(&buf_resp);
153
154 return ret;
155}
156
157/*
158 * An arbitrary fixed address to verify that the application instance

Callers 1

test_app_cbFunction · 0.85

Calls 2

strbuf_addfFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected