Commit e9f8f856 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(get_scheduling): New request.

(may_change_scheduling): New static function.
(set_scheduling): New request.
parent f5009730
/*
* $Id: connections.c,v 0.120 2003/08/12 13:14:02 ceder Exp $
* $Id: connections.c,v 0.121 2003/08/14 17:08:34 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -88,6 +88,7 @@
#include "timeval-util.h"
#include "stats.h"
#include "string-malloc.h"
#include "manipulate.h"
oop_source_sys * kom_server_oop_src = NULL;
struct isc_mcb * kom_server_mcb = NULL;
......@@ -1162,3 +1163,111 @@ server_idle(void)
{
return is_idle;
}
Success
get_scheduling(Session_no session_no,
Scheduling_info *result)
{
Connection *cptr;
CHK_CONNECTION(FAILURE);
if (session_no != 0 && session_no != active_connection->session_no)
CHK_LOGIN(FAILURE);
if ((cptr = get_conn_by_number(session_no)) == NULL
|| !handshake_ok(cptr, 0))
{
kom_errno = KOM_UNDEF_SESSION;
err_stat = session_no;
return FAILURE;
}
result->priority = 0;
result->weight = 1;
return OK;
}
static Bool
may_change_scheduling(Session_no session_no,
Connection *cptr)
{
if (session_no == 0)
return TRUE;
if (session_no == active_connection->session_no)
return TRUE;
if (cptr->pers_no == 0
&& (ENA_C(active_connection, admin, 2)
|| ENA_C(active_connection, wheel, 8)))
return TRUE;
if (has_access(cptr->pers_no, active_connection, unlimited))
return TRUE;
return FALSE;
}
Success
set_scheduling(Session_no session_no,
unsigned short priority,
unsigned short weight)
{
Connection *cptr;
CHK_CONNECTION(FAILURE);
if (weight == 0)
{
kom_errno = KOM_WEIGHT_ZERO;
err_stat = 0;
return FAILURE;
}
if (session_no != 0 && session_no != active_connection->session_no)
CHK_LOGIN(FAILURE);
if ((cptr = get_conn_by_number(session_no)) == NULL
|| !handshake_ok(cptr, 0))
{
kom_errno = KOM_UNDEF_SESSION;
err_stat = session_no;
return FAILURE;
}
if (!may_change_scheduling(session_no, cptr))
{
kom_errno = KOM_ACCESS;
err_stat = session_no;
return FAILURE;
}
if (priority > 0)
{
kom_errno = KOM_INDEX_OUT_OF_RANGE;
err_stat = 0;
return FAILURE;
}
#if 0
/* Since priority is unsigned this can never happen. */
if (priority < 0)
{
kom_errno = KOM_PRIORITY_DENIED;
err_stat = 0;
return FAILURE;
}
#endif
if (weight > 1)
{
kom_errno = KOM_WEIGHT_DENIED;
err_stat = 1;
return FAILURE;
}
return OK;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment