|
|
3034d1 |
/*********************************************************/
|
|
|
3034d1 |
/* toksvc: a framework-native token broker service */
|
|
|
3034d1 |
/* Copyright (C) 2020 Z. Gilboa */
|
|
|
3034d1 |
/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */
|
|
|
3034d1 |
/*********************************************************/
|
|
|
3034d1 |
|
|
|
3034d1 |
#include <psxtypes/psxtypes.h>
|
|
|
3034d1 |
#include <ntapi/ntapi.h>
|
|
|
3034d1 |
|
|
|
3034d1 |
#include <toksvc/toksvc.h>
|
|
|
3034d1 |
#include "toksvc_daemon_impl.h"
|
|
|
3034d1 |
#include "toksvc_driver_impl.h"
|
|
|
3034d1 |
|
|
|
3034d1 |
int32_t __stdcall toks_daemon_cancel(struct toks_daemon_ctx * dctx)
|
|
|
3034d1 |
{
|
|
|
3034d1 |
nt_tty_port_msg * msg;
|
|
|
3034d1 |
nt_cid * cid;
|
|
|
3034d1 |
struct toks_waiter * waiter;
|
|
|
3034d1 |
struct toks_waiter * waitcap;
|
|
|
3034d1 |
int nwaiters;
|
|
|
3034d1 |
|
|
|
3034d1 |
msg = &dctx->reply;
|
|
|
3034d1 |
cid = &msg->header.client_id;
|
|
|
3034d1 |
nwaiters = toks_get_driver_nwaiters(dctx->driver_ctx);
|
|
|
3034d1 |
|
|
|
3034d1 |
if (nwaiters == 0)
|
|
|
3034d1 |
return NT_STATUS_NOT_FOUND;
|
|
|
3034d1 |
|
|
|
3034d1 |
waiter = dctx->waiter_first;
|
|
|
3034d1 |
waitcap = &waiter[nwaiters];
|
|
|
3034d1 |
|
|
|
3034d1 |
if (waitcap > dctx->waiter_cap)
|
|
|
3034d1 |
waitcap = dctx->waiter_cap;
|
|
|
3034d1 |
|
|
|
3034d1 |
for (; waiter
|
|
|
3034d1 |
if (waiter->msg.header.client_id.process_id == cid->process_id) {
|
|
|
3034d1 |
if (waiter->msg.header.client_id.thread_id == cid->thread_id) {
|
|
|
3034d1 |
waiter->msg.header.msg_id = 0;
|
|
|
eed428 |
toks_set_driver_nwaiters(dctx->driver_ctx,--nwaiters);
|
|
|
3034d1 |
return NT_STATUS_CANCELLED;
|
|
|
3034d1 |
}
|
|
|
3034d1 |
}
|
|
|
3034d1 |
}
|
|
|
3034d1 |
|
|
|
3034d1 |
if (nwaiters < (dctx->waiter_cap - dctx->waiter_first))
|
|
|
3034d1 |
return NT_STATUS_NOT_FOUND;
|
|
|
3034d1 |
|
|
|
3034d1 |
waiter = dctx->waiter_base;
|
|
|
3034d1 |
waitcap = &waiter[nwaiters - (dctx->waiter_cap-dctx->waiter_first)];
|
|
|
3034d1 |
|
|
|
3034d1 |
for (; waiter
|
|
|
3034d1 |
if (waiter->msg.header.client_id.process_id == cid->process_id) {
|
|
|
3034d1 |
if (waiter->msg.header.client_id.thread_id == cid->thread_id) {
|
|
|
3034d1 |
waiter->msg.header.msg_id = 0;
|
|
|
eed428 |
toks_set_driver_nwaiters(dctx->driver_ctx,--nwaiters);
|
|
|
3034d1 |
return NT_STATUS_CANCELLED;
|
|
|
3034d1 |
}
|
|
|
3034d1 |
}
|
|
|
3034d1 |
}
|
|
|
3034d1 |
|
|
|
3034d1 |
return NT_STATUS_NOT_FOUND;
|
|
|
3034d1 |
}
|