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

Function read_http_request

ds4_server.c:11120–11166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11118 if (r && r->model_syntax == SERVER_MODEL_SYNTAX_GLM) {
11119 return build_invalid_glm_tool_error_suffix(r, thinking, detail);
11120 }
11121 return build_invalid_dsml_tool_error_suffix(r, thinking, detail);
11122}
11123
11124static int server_next_prefill_slot_locked(const server *s) {
11125 if (!s || s->slot_count <= 0) return -1;
11126 for (int n = 1; n <= s->slot_count; n++) {
11127 int id = (s->last_prefill_slot + n) % s->slot_count;
11128 if (s->slots[id].prefill_waiting) return id;
11129 }
11130 return -1;
11131}
11132
11133static bool server_prefill_enter(server *s, server_slot *slot) {
11134 if (!s || !slot || slot_job_cancelled(slot)) return false;
11135 if (!s->batched_mode) {
11136 pthread_mutex_lock(&s->inference_mu);
11137 if (slot_job_cancelled(slot)) {
11138 pthread_mutex_unlock(&s->inference_mu);
11139 return false;
11140 }
11141 return true;
11142 }
11143
11144 pthread_mutex_lock(&s->model_mu);
11145 slot->prefill_waiting = true;
11146 pthread_cond_broadcast(&s->model_cv);
11147 while (!g_stop_requested && !slot_job_cancelled(slot) &&
11148 (s->model_busy || s->decode_pending > 0 ||
11149 server_next_prefill_slot_locked(s) != slot->id)) {
11150 pthread_cond_wait(&s->model_cv, &s->model_mu);
11151 }
11152 if (g_stop_requested || slot_job_cancelled(slot)) {
11153 slot->prefill_waiting = false;
11154 pthread_cond_broadcast(&s->model_cv);
11155 pthread_mutex_unlock(&s->model_mu);
11156 return false;
11157 }
11158 slot->prefill_waiting = false;
11159 s->last_prefill_slot = slot->id;
11160 s->model_busy = true;
11161 pthread_mutex_unlock(&s->model_mu);
11162 pthread_mutex_lock(&s->inference_mu);
11163 return true;
11164}
11165
11166static void server_prefill_leave(server *s) {
11167 if (!s) return;
11168 pthread_mutex_unlock(&s->inference_mu);
11169 if (!s->batched_mode) return;

Callers 1

client_mainFunction · 0.85

Calls 5

header_endFunction · 0.85
content_lengthFunction · 0.85
buf_appendFunction · 0.70
xmallocFunction · 0.70
buf_freeFunction · 0.70

Tested by

no test coverage detected