MCPcopy Create free account
hub / github.com/antirez/ds4 / dist_send_hello

Function dist_send_hello

ds4_distributed.c:1762–1789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1760 * ========================================================================= */
1761
1762static int dist_send_hello(ds4_engine *engine, const ds4_dist_options *opt, int ctx_size, uint32_t listen_port, int fd) {
1763 uint32_t n_layers = (uint32_t)ds4_engine_layer_count(engine);
1764 const char *model_name = ds4_engine_model_name(engine);
1765 if (!model_name) model_name = "unknown";
1766 size_t model_name_len = strlen(model_name);
1767 if (model_name_len > DS4_DIST_MAX_MODEL_NAME) model_name_len = DS4_DIST_MAX_MODEL_NAME;
1768
1769 ds4_dist_hello_fixed h = {
1770 (uint32_t)ds4_engine_model_id(engine),
1771 (uint32_t)ds4_engine_routed_quant_bits(engine),
1772 opt->layers.start,
1773 dist_resolved_layer_end(opt, n_layers),
1774 opt->layers.has_output ? 1u : 0u,
1775 1u,
1776 ctx_size > 0 ? (uint32_t)ctx_size : 0u,
1777 n_layers,
1778 listen_port,
1779 (uint32_t)model_name_len
1780 };
1781 ds4_dist_hello_fixed wire = h;
1782 dist_hello_to_wire(&wire);
1783
1784 uint32_t bytes = (uint32_t)sizeof(wire) + (uint32_t)model_name_len;
1785 if (dist_write_frame_header(fd, DS4_DIST_MSG_HELLO, bytes) != 0) return -1;
1786 if (dist_write_full(fd, &wire, sizeof(wire)) != 0) return -1;
1787 if (model_name_len && dist_write_full(fd, model_name, model_name_len) != 0) return -1;
1788 return 0;
1789}
1790
1791static int dist_recv_hello(int fd, ds4_dist_hello_fixed *hello, char *model_name, size_t model_name_cap, char *err, size_t errlen) {
1792 uint32_t type = 0, bytes = 0;

Callers 1

dist_run_workerFunction · 0.85

Calls 8

ds4_engine_layer_countFunction · 0.85
ds4_engine_model_nameFunction · 0.85
ds4_engine_model_idFunction · 0.85
dist_resolved_layer_endFunction · 0.85
dist_hello_to_wireFunction · 0.85
dist_write_frame_headerFunction · 0.85
dist_write_fullFunction · 0.85

Tested by

no test coverage detected