Rework the start session method in SCP
The start session method is reworked to pass a response back to the client. If the method was successful, a session list entry is created. This is different to the provious behaviour, where we created the session list entry unconditionally. This new arrangement means that we need a different way to avoid a race condition where two users may try to create a session at the same time, and end up with the same display. We do this by keeping track of newly allocated displays as part of the SCP connections. When we allocate a display, the SCP connection displays are also taken into account.
This commit is contained in:
+22
-1
@@ -33,6 +33,7 @@
|
||||
#include "list.h"
|
||||
#include "os_calls.h"
|
||||
#include "scp_list.h"
|
||||
#include "set_int.h"
|
||||
#include "trans.h"
|
||||
|
||||
#define SCP_LIST_ITEM_IN_USE(sli) \
|
||||
@@ -125,7 +126,7 @@ scp_list_item_new(void)
|
||||
{
|
||||
g_snprintf(result->peername, sizeof(result->peername), "unknown");
|
||||
result->uid = (uid_t) -1;
|
||||
|
||||
result->session_display = -1;
|
||||
if (!list_add_item(g_scp_list, (tintptr)result))
|
||||
{
|
||||
g_free(result);
|
||||
@@ -259,3 +260,23 @@ scp_list_check_wait_objs(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void
|
||||
scp_list_get_create_session_displays(struct set_int *alloc_displays)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < g_scp_list->count; ++i)
|
||||
{
|
||||
struct scp_list_item *sli;
|
||||
|
||||
sli = (struct scp_list_item *)list_get_item(g_scp_list, i);
|
||||
|
||||
if (SCP_LIST_ITEM_IN_USE(sli) &&
|
||||
sli->create_session_in_progress &&
|
||||
sli->session_display >= 0)
|
||||
{
|
||||
set_int_add(alloc_displays, sli->session_display);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user