Lines Matching refs:ctx

70   struct poll_ctx* ctx;  in uv_fs_poll_start()  local
80 ctx = uv__calloc(1, sizeof(*ctx) + len); in uv_fs_poll_start()
82 if (ctx == NULL) in uv_fs_poll_start()
85 ctx->loop = loop; in uv_fs_poll_start()
86 ctx->poll_cb = cb; in uv_fs_poll_start()
87 ctx->interval = interval ? interval : 1; in uv_fs_poll_start()
88 ctx->start_time = uv_now(loop); in uv_fs_poll_start()
89 ctx->parent_handle = handle; in uv_fs_poll_start()
90 memcpy(ctx->path, path, len + 1); in uv_fs_poll_start()
92 err = uv_timer_init(loop, &ctx->timer_handle); in uv_fs_poll_start()
96 ctx->timer_handle.flags |= UV_HANDLE_INTERNAL; in uv_fs_poll_start()
97 uv__handle_unref(&ctx->timer_handle); in uv_fs_poll_start()
99 err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb); in uv_fs_poll_start()
104 ctx->previous = handle->poll_ctx; in uv_fs_poll_start()
105 handle->poll_ctx = ctx; in uv_fs_poll_start()
111 uv__free(ctx); in uv_fs_poll_start()
117 struct poll_ctx* ctx; in uv_fs_poll_stop() local
122 ctx = handle->poll_ctx; in uv_fs_poll_stop()
123 assert(ctx != NULL); in uv_fs_poll_stop()
124 assert(ctx->parent_handle == handle); in uv_fs_poll_stop()
129 if (uv_is_active((uv_handle_t*)&ctx->timer_handle)) in uv_fs_poll_stop()
130 uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); in uv_fs_poll_stop()
139 struct poll_ctx* ctx; in uv_fs_poll_getpath() local
147 ctx = handle->poll_ctx; in uv_fs_poll_getpath()
148 assert(ctx != NULL); in uv_fs_poll_getpath()
150 required_len = strlen(ctx->path); in uv_fs_poll_getpath()
156 memcpy(buffer, ctx->path, required_len); in uv_fs_poll_getpath()
173 struct poll_ctx* ctx; in timer_cb() local
175 ctx = container_of(timer, struct poll_ctx, timer_handle); in timer_cb()
176 assert(ctx->parent_handle != NULL); in timer_cb()
177 assert(ctx->parent_handle->poll_ctx == ctx); in timer_cb()
178 ctx->start_time = uv_now(ctx->loop); in timer_cb()
180 if (uv_fs_stat(ctx->loop, &ctx->fs_req, ctx->path, poll_cb)) in timer_cb()
187 struct poll_ctx* ctx; in poll_cb() local
191 ctx = container_of(req, struct poll_ctx, fs_req); in poll_cb()
192 handle = ctx->parent_handle; in poll_cb()
198 if (ctx->busy_polling != req->result) { in poll_cb()
199 ctx->poll_cb(ctx->parent_handle, in poll_cb()
201 &ctx->statbuf, in poll_cb()
203 ctx->busy_polling = req->result; in poll_cb()
210 if (ctx->busy_polling != 0) in poll_cb()
211 if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf)) in poll_cb()
212 ctx->poll_cb(ctx->parent_handle, 0, &ctx->statbuf, statbuf); in poll_cb()
214 ctx->statbuf = *statbuf; in poll_cb()
215 ctx->busy_polling = 1; in poll_cb()
221 uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb); in poll_cb()
226 interval = ctx->interval; in poll_cb()
227 interval -= (uv_now(ctx->loop) - ctx->start_time) % interval; in poll_cb()
229 if (uv_timer_start(&ctx->timer_handle, timer_cb, interval, 0)) in poll_cb()
235 struct poll_ctx* ctx; in timer_close_cb() local
240 ctx = container_of(timer, struct poll_ctx, timer_handle); in timer_close_cb()
241 handle = ctx->parent_handle; in timer_close_cb()
242 if (ctx == handle->poll_ctx) { in timer_close_cb()
243 handle->poll_ctx = ctx->previous; in timer_close_cb()
248 it != ctx; in timer_close_cb()
252 last->previous = ctx->previous; in timer_close_cb()
254 uv__free(ctx); in timer_close_cb()