ReactOS  0.4.12-dev-43-g63b00d8
nfs41_session.c File Reference
#include <windows.h>
#include <process.h>
#include <stdio.h>
#include "nfs41_ops.h"
#include "nfs41_callback.h"
#include "util.h"
#include "daemon_debug.h"
Include dependency graph for nfs41_session.c:

Go to the source code of this file.

Macros

#define MAX_SLOTS_DELAY   2000 /* in milliseconds */
 

Functions

static int slot_table_avail (IN const nfs41_slot_table *table)
 
static void init_slot_table (nfs41_slot_table *table)
 
static void resize_slot_table (IN nfs41_slot_table *table, IN uint32_t target_highest_slotid)
 
void nfs41_session_bump_seq (IN nfs41_session *session, IN uint32_t slotid, IN uint32_t target_highest_slotid)
 
void nfs41_session_free_slot (IN nfs41_session *session, IN uint32_t slotid)
 
void nfs41_session_get_slot (IN nfs41_session *session, OUT uint32_t *slot, OUT uint32_t *seqid, OUT uint32_t *highest)
 
int nfs41_session_recall_slot (IN nfs41_session *session, IN OUT uint32_t target_highest_slotid)
 
int nfs41_session_bad_slot (IN nfs41_session *session, IN OUT nfs41_sequence_args *args)
 
void nfs41_session_sequence (nfs41_sequence_args *args, nfs41_session *session, bool_t cachethis)
 
static unsigned int WINAPI renew_session (void *args)
 
static int session_alloc (IN nfs41_client *client, OUT nfs41_session **session_out)
 
int nfs41_session_create (IN nfs41_client *client, IN nfs41_session **session_out)
 
int nfs41_session_renew (IN nfs41_session *session)
 
int nfs41_session_set_lease (IN nfs41_session *session, IN uint32_t lease_time)
 
void nfs41_session_free (IN nfs41_session *session)
 

Macro Definition Documentation

◆ MAX_SLOTS_DELAY

#define MAX_SLOTS_DELAY   2000 /* in milliseconds */

Definition at line 34 of file nfs41_session.c.

Referenced by nfs41_session_bad_slot(), and nfs41_session_recall_slot().

Function Documentation

◆ init_slot_table()

static void init_slot_table ( nfs41_slot_table table)
static

Definition at line 45 of file nfs41_session.c.

Referenced by nfs41_session_renew(), and session_alloc().

46 {
47  uint32_t i;
48  EnterCriticalSection(&table->lock);
50  for (i = 0; i < NFS41_MAX_NUM_SLOTS; i++) {
51  table->seq_nums[i] = 1;
52  table->used_slots[i] = 0;
53  }
54  table->highest_used = table->num_used = 0;
55  table->target_delay = 0;
56 
57  /* wake any threads waiting on a slot */
58  if (slot_table_avail(table))
60  LeaveCriticalSection(&table->lock);
61 }
#define NFS41_MAX_NUM_SLOTS
Definition: nfs41.h:218
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t seq_nums[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:220
uint32_t highest_used
Definition: nfs41.h:223
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static int slot_table_avail(IN const nfs41_slot_table *table)
Definition: nfs41_session.c:38
VOID WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
Definition: sync.c:137
uint32_t num_used
Definition: nfs41.h:224
uint32_t used_slots[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:221
ULONGLONG target_delay
Definition: nfs41.h:225
uint32_t max_slots
Definition: nfs41.h:222
UINT32 uint32_t
Definition: types.h:75
CONDITION_VARIABLE cond
Definition: nfs41.h:227
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ nfs41_session_bad_slot()

int nfs41_session_bad_slot ( IN nfs41_session session,
IN OUT nfs41_sequence_args args 
)

Definition at line 185 of file nfs41_session.c.

188 {
189  nfs41_slot_table *table = &session->table;
190  int status = NFS4ERR_BADSLOT;
191 
192  if (args->sa_slotid == 0) {
193  eprintf("server bug detected: NFS4ERR_BADSLOT for slotid=0\n");
194  goto out;
195  }
196 
197  /* avoid using any slots >= bad_slotid */
198  EnterCriticalSection(&table->lock);
199  if (table->max_slots > args->sa_slotid) {
200  resize_slot_table(table, args->sa_slotid);
202  }
203  LeaveCriticalSection(&table->lock);
204 
205  /* get a new slot */
206  nfs41_session_free_slot(session, args->sa_slotid);
207  nfs41_session_get_slot(session, &args->sa_slotid,
208  &args->sa_sequenceid, &args->sa_highest_slotid);
209  status = NFS4_OK;
210 out:
211  return status;
212 }
#define MAX_SLOTS_DELAY
Definition: nfs41_session.c:34
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: match.c:390
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
ULONGLONG target_delay
Definition: nfs41.h:225
static FILE * out
Definition: regtests2xml.c:44
void nfs41_session_get_slot(IN nfs41_session *session, OUT uint32_t *slot, OUT uint32_t *seqid, OUT uint32_t *highest)
uint32_t max_slots
Definition: nfs41.h:222
void nfs41_session_free_slot(IN nfs41_session *session, IN uint32_t slotid)
static void resize_slot_table(IN nfs41_slot_table *table, IN uint32_t target_highest_slotid)
Definition: nfs41_session.c:63
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ nfs41_session_bump_seq()

void nfs41_session_bump_seq ( IN nfs41_session session,
IN uint32_t  slotid,
IN uint32_t  target_highest_slotid 
)

Definition at line 80 of file nfs41_session.c.

Referenced by compound_encode_send_decode(), and nfs41_root_session().

84 {
85  nfs41_slot_table *table = &session->table;
86 
87  AcquireSRWLockShared(&session->client->session_lock);
88  EnterCriticalSection(&table->lock);
89 
90  if (slotid < NFS41_MAX_NUM_SLOTS)
91  table->seq_nums[slotid]++;
92 
93  /* adjust max_slots in response to changes in target_highest_slotid,
94  * but not immediately after a CB_RECALL_SLOT or NFS4ERR_BADSLOT error */
95  if (table->target_delay <= GetTickCount64())
96  resize_slot_table(table, target_highest_slotid);
97 
98  LeaveCriticalSection(&table->lock);
99  ReleaseSRWLockShared(&session->client->session_lock);
100 }
#define NFS41_MAX_NUM_SLOTS
Definition: nfs41.h:218
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
uint32_t seq_nums[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:220
ULONGLONG target_delay
Definition: nfs41.h:225
static void resize_slot_table(IN nfs41_slot_table *table, IN uint32_t target_highest_slotid)
Definition: nfs41_session.c:63
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_create()

int nfs41_session_create ( IN nfs41_client client,
IN nfs41_session **  session_out 
)

Definition at line 278 of file nfs41_session.c.

Referenced by nfs41_root_session(), and root_client_create().

281 {
282  nfs41_session *session;
283  int status;
284 
285  status = session_alloc(client, &session);
286  if (status) {
287  eprintf("session_alloc() failed with %d\n", status);
288  goto out;
289  }
290 
291  AcquireSRWLockShared(&client->exid_lock);
292  if (client->rpc->needcb)
295  ReleaseSRWLockShared(&client->exid_lock);
296 
297  status = nfs41_create_session(client, session, TRUE);
298  if (status) {
299  eprintf("nfs41_create_session failed %d\n", status);
300  status = ERROR_BAD_NET_RESP;
301  goto out_err;
302  }
303 
305  client->session = session;
306  session->isValidState = TRUE;
308  *session_out = session;
309 out:
310  return status;
311 
312 out_err:
313  nfs41_session_free(session);
314  goto out;
315 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
#define TRUE
Definition: types.h:120
uint32_t flags
Definition: nfs41.h:265
SRWLOCK session_lock
Definition: nfs41.h:200
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define ERROR_BAD_NET_RESP
Definition: winerror.h:150
nfs41_client * client
Definition: nfs41.h:256
bool_t isValidState
Definition: nfs41.h:264
#define CREATE_SESSION4_FLAG_PERSIST
Definition: nfs41_const.h:307
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
static int session_alloc(IN nfs41_client *client, OUT nfs41_session **session_out)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
#define CREATE_SESSION4_FLAG_CONN_BACK_CHAN
Definition: nfs41_const.h:308
int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_recovery)
Definition: nfs41_ops.c:101
void nfs41_session_free(IN nfs41_session *session)
static SERVICE_STATUS status
Definition: service.c:31
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_free()

void nfs41_session_free ( IN nfs41_session session)

Definition at line 363 of file nfs41_session.c.

Referenced by nfs41_client_free(), nfs41_root_session(), and nfs41_session_create().

365 {
366  AcquireSRWLockExclusive(&session->client->session_lock);
367  if (valid_handle(session->renew_thread)) {
368  dprintf(1, "nfs41_session_free: terminating session renewal thread\n");
369  if (!TerminateThread(session->renew_thread, NO_ERROR))
370  eprintf("failed to terminate renewal thread %p\n",
371  session->renew_thread);
372  }
373 
374  if (session->isValidState) {
375  session->client->rpc->is_valid_session = FALSE;
376  nfs41_destroy_session(session);
377  }
378  DeleteCriticalSection(&session->table.lock);
379  ReleaseSRWLockExclusive(&session->client->session_lock);
380  free(session);
381 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
Definition: thread.c:549
#define free
Definition: debug_ros.c:5
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
#define NO_ERROR
Definition: dderror.h:5
__inline int valid_handle(HANDLE handle)
Definition: util.h:281
#define dprintf
Definition: regdump.c:33
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
int nfs41_destroy_session(IN nfs41_session *session)
Definition: nfs41_ops.c:214

◆ nfs41_session_free_slot()

void nfs41_session_free_slot ( IN nfs41_session session,
IN uint32_t  slotid 
)

Definition at line 102 of file nfs41_session.c.

Referenced by compound_encode_send_decode(), nfs41_root_session(), and nfs41_session_bad_slot().

105 {
106  nfs41_slot_table *table = &session->table;
107 
108  AcquireSRWLockShared(&session->client->session_lock);
109  EnterCriticalSection(&table->lock);
110 
111  /* flag the slot as unused */
112  if (slotid < NFS41_MAX_NUM_SLOTS && table->used_slots[slotid]) {
113  table->used_slots[slotid] = 0;
114  table->num_used--;
115  }
116  /* update highest_used if necessary */
117  if (slotid == table->highest_used) {
118  while (table->highest_used && !table->used_slots[table->highest_used])
119  table->highest_used--;
120  }
121  dprintf(3, "freeing slot#=%d used=%d highest=%d\n",
122  slotid, table->num_used, table->highest_used);
123 
124  /* wake any threads waiting on a slot */
125  if (slot_table_avail(table))
127 
128  LeaveCriticalSection(&table->lock);
129  ReleaseSRWLockShared(&session->client->session_lock);
130 }
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t highest_used
Definition: nfs41.h:223
static int slot_table_avail(IN const nfs41_slot_table *table)
Definition: nfs41_session.c:38
VOID WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
Definition: sync.c:137
#define dprintf
Definition: regdump.c:33
uint32_t num_used
Definition: nfs41.h:224
uint32_t used_slots[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:221
CONDITION_VARIABLE cond
Definition: nfs41.h:227
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_get_slot()

void nfs41_session_get_slot ( IN nfs41_session session,
OUT uint32_t slot,
OUT uint32_t seqid,
OUT uint32_t highest 
)

Definition at line 132 of file nfs41_session.c.

Referenced by compound_encode_send_decode(), nfs41_root_session(), nfs41_session_bad_slot(), and nfs41_session_sequence().

137 {
138  nfs41_slot_table *table = &session->table;
139  uint32_t i;
140 
141  AcquireSRWLockShared(&session->client->session_lock);
142  EnterCriticalSection(&table->lock);
143 
144  /* wait for an available slot */
145  while (!slot_table_avail(table))
146  SleepConditionVariableCS(&table->cond, &table->lock, INFINITE);
147 
148  for (i = 0; i < table->max_slots; i++) {
149  if (table->used_slots[i])
150  continue;
151 
152  table->used_slots[i] = 1;
153  table->num_used++;
154  if (i > table->highest_used)
155  table->highest_used = i;
156 
157  *slot = i;
158  *seqid = table->seq_nums[i];
159  *highest = table->highest_used;
160  break;
161  }
162  LeaveCriticalSection(&table->lock);
163  ReleaseSRWLockShared(&session->client->session_lock);
164 
165  dprintf(2, "session %p: using slot#=%d with seq#=%d highest=%d\n",
166  session, *slot, *seqid, *highest);
167 }
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t seq_nums[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:220
uint32_t highest_used
Definition: nfs41.h:223
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static int slot_table_avail(IN const nfs41_slot_table *table)
Definition: nfs41_session.c:38
#define dprintf
Definition: regdump.c:33
uint32_t num_used
Definition: nfs41.h:224
uint32_t used_slots[NFS41_MAX_NUM_SLOTS]
Definition: nfs41.h:221
Definition: vfat.h:189
uint32_t max_slots
Definition: nfs41.h:222
BOOL WINAPI SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, PCRITICAL_SECTION CriticalSection, DWORD Timeout)
Definition: sync.c:105
UINT32 uint32_t
Definition: types.h:75
CONDITION_VARIABLE cond
Definition: nfs41.h:227
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INFINITE
Definition: serial.h:102
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_recall_slot()

int nfs41_session_recall_slot ( IN nfs41_session session,
IN OUT uint32_t  target_highest_slotid 
)

Definition at line 169 of file nfs41_session.c.

Referenced by handle_cb_recall_slot(), and nfs41_root_session().

172 {
173  nfs41_slot_table *table = &session->table;
174 
175  AcquireSRWLockShared(&session->client->session_lock);
176  EnterCriticalSection(&table->lock);
177  resize_slot_table(table, target_highest_slotid);
179  LeaveCriticalSection(&table->lock);
180  ReleaseSRWLockShared(&session->client->session_lock);
181 
182  return NFS4_OK;
183 }
#define MAX_SLOTS_DELAY
Definition: nfs41_session.c:34
CRITICAL_SECTION lock
Definition: nfs41.h:226
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
ULONGLONG target_delay
Definition: nfs41.h:225
static void resize_slot_table(IN nfs41_slot_table *table, IN uint32_t target_highest_slotid)
Definition: nfs41_session.c:63
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:61
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
Definition: sync.c:89

◆ nfs41_session_renew()

int nfs41_session_renew ( IN nfs41_session session)

Definition at line 318 of file nfs41_session.c.

Referenced by nfs41_recover_session(), and nfs41_root_session().

320 {
321  int status;
322 
323  AcquireSRWLockExclusive(&session->client->session_lock);
324  session->cb_session.cb_seqnum = 0;
325  init_slot_table(&session->table);
326 
327  status = nfs41_create_session(session->client, session, FALSE);
328  ReleaseSRWLockExclusive(&session->client->session_lock);
329  return status;
330 }
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:54
static void init_slot_table(nfs41_slot_table *table)
Definition: nfs41_session.c:45
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
Definition: sync.c:82
int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_recovery)
Definition: nfs41_ops.c:101
static SERVICE_STATUS status
Definition: service.c:31

◆ nfs41_session_sequence()

void nfs41_session_sequence ( nfs41_sequence_args args,
nfs41_session session,
bool_t  cachethis 
)

Definition at line 214 of file nfs41_session.c.

Referenced by lookup_rpc(), nfs41_access(), nfs41_close(), nfs41_commit(), nfs41_create(), nfs41_delegpurge(), nfs41_delegreturn(), nfs41_free_stateid(), nfs41_fs_locations(), nfs41_getattr(), nfs41_link(), nfs41_lock(), nfs41_open(), nfs41_read(), nfs41_readdir(), nfs41_readlink(), nfs41_reclaim_complete(), nfs41_remove(), nfs41_rename(), nfs41_root_session(), nfs41_rpc_openattr(), nfs41_secinfo(), nfs41_secinfo_noname(), nfs41_send_sequence(), nfs41_setattr(), nfs41_superblock_getattr(), nfs41_test_stateid(), nfs41_unlock(), nfs41_want_delegation(), nfs41_write(), pnfs_rpc_getdeviceinfo(), pnfs_rpc_layoutcommit(), pnfs_rpc_layoutget(), pnfs_rpc_layoutreturn(), and rpc_array_putfh().

218 {
219  nfs41_session_get_slot(session, &args->sa_slotid,
220  &args->sa_sequenceid, &args->sa_highest_slotid);
221  args->sa_sessionid = session->session_id;
222  args->sa_cachethis = cachethis;
223 }
uint32_t sa_highest_slotid
Definition: nfs41_ops.h:232
unsigned char session_id[NFS4_SESSIONID_SIZE]
Definition: nfs41.h:257
uint32_t sa_sequenceid
Definition: nfs41_ops.h:230
unsigned char * sa_sessionid
Definition: nfs41_ops.h:229
void nfs41_session_get_slot(IN nfs41_session *session, OUT uint32_t *slot, OUT uint32_t *seqid, OUT uint32_t *highest)

◆ nfs41_session_set_lease()

int nfs41_session_set_lease ( IN nfs41_session session,
IN uint32_t  lease_time 
)

Definition at line 332 of file nfs41_session.c.

Referenced by nfs41_root_session(), and session_get_lease().

335 {
336  int status = NO_ERROR;
338 
339  if (valid_handle(session->renew_thread)) {
340  eprintf("nfs41_session_set_lease(): session "
341  "renewal thread already started!\n");
342  goto out;
343  }
344 
345  if (lease_time == 0) {
346  eprintf("nfs41_session_set_lease(): invalid lease_time=0\n");
347  status = ERROR_INVALID_PARAMETER;
348  goto out;
349  }
350 
351  session->lease_time = lease_time;
352  session->renew_thread = (HANDLE)_beginthreadex(NULL,
353  0, renew_session, session, 0, &thread_id);
354  if (!valid_handle(session->renew_thread)) {
355  status = GetLastError();
356  eprintf("_beginthreadex failed %d\n", status);
357  goto out;
358  }
359 out:
360  return status;
361 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void eprintf(LPCSTR format,...)
Definition: daemon_debug.c:86
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
#define NO_ERROR
Definition: dderror.h:5
__inline int valid_handle(HANDLE handle)
Definition: util.h:281
smooth NULL
Definition: ftsmooth.c:416
static FILE * out
Definition: regtests2xml.c:44
PVOID HANDLE
Definition: typedefs.h:71
static DWORD thread_id
Definition: protocol.c:158
UINT32 uint32_t
Definition: types.h:75
static unsigned int WINAPI renew_session(void *args)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ renew_session()

static unsigned int WINAPI renew_session ( void args)
static

Definition at line 227 of file nfs41_session.c.

Referenced by nfs41_session_set_lease().

228 {
229  int status = NO_ERROR;
230  nfs41_session *session = (nfs41_session *)args;
231  /* sleep for 2/3 of lease_time */
232  const uint32_t sleep_time = (2 * session->lease_time*1000)/3;
233 
234  dprintf(1, "Creating renew_session thread: %p\n", session->renew_thread);
235  while(1) {
236  dprintf(1, "Going to sleep for %dmsecs\n", sleep_time);
237  Sleep(sleep_time);
238  status = nfs41_send_sequence(session);
239  if (status)
240  dprintf(1, "renewal thread: nfs41_send_sequence failed %d\n", status);
241  }
242  return status;
243 }
int nfs41_send_sequence(IN nfs41_session *session)
Definition: nfs41_ops.c:1599
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
#define NO_ERROR
Definition: dderror.h:5
uint32_t lease_time
Definition: nfs41.h:260
#define dprintf
Definition: regdump.c:33
HANDLE renew_thread
Definition: nfs41.h:263
UINT32 uint32_t
Definition: types.h:75
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ resize_slot_table()

static void resize_slot_table ( IN nfs41_slot_table table,
IN uint32_t  target_highest_slotid 
)
static

Definition at line 63 of file nfs41_session.c.

Referenced by nfs41_session_bad_slot(), nfs41_session_bump_seq(), and nfs41_session_recall_slot().

66 {
67  if (target_highest_slotid >= NFS41_MAX_NUM_SLOTS)
68  target_highest_slotid = NFS41_MAX_NUM_SLOTS - 1;
69 
70  if (table->max_slots != target_highest_slotid + 1) {
71  dprintf(2, "updated max_slots %u to %u\n",
72  table->max_slots, target_highest_slotid + 1);
73  table->max_slots = target_highest_slotid + 1;
74 
77  }
78 }
#define NFS41_MAX_NUM_SLOTS
Definition: nfs41.h:218
static int slot_table_avail(IN const nfs41_slot_table *table)
Definition: nfs41_session.c:38
VOID WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
Definition: sync.c:137
#define dprintf
Definition: regdump.c:33

◆ session_alloc()

static int session_alloc ( IN nfs41_client client,
OUT nfs41_session **  session_out 
)
static

Definition at line 246 of file nfs41_session.c.

Referenced by nfs41_session_create().

249 {
250  nfs41_session *session;
251  int status = NO_ERROR;
252 
253  session = calloc(1, sizeof(nfs41_session));
254  if (session == NULL) {
255  status = GetLastError();
256  goto out;
257  }
258  session->client = client;
260  session->isValidState = FALSE;
261 
264 
265  init_slot_table(&session->table);
266 
267  //initialize session lock
268  InitializeSRWLock(&client->session_lock);
269 
270  /* initialize the back channel */
272 
273  *session_out = session;
274 out:
275  return status;
276 }
void nfs41_callback_session_init(IN nfs41_session *session)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void init_slot_table(nfs41_slot_table *table)
Definition: nfs41_session.c:45
nfs41_slot_table table
Definition: nfs41.h:261
CRITICAL_SECTION lock
Definition: nfs41.h:226
#define NO_ERROR
Definition: dderror.h:5
nfs41_client * client
Definition: nfs41.h:256
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
bool_t isValidState
Definition: nfs41.h:264
HANDLE renew_thread
Definition: nfs41.h:263
static FILE * client
Definition: client.c:41
static FILE * out
Definition: regtests2xml.c:44
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
Definition: sync.c:75
VOID WINAPI InitializeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
Definition: sync.c:68
CONDITION_VARIABLE cond
Definition: nfs41.h:227
#define calloc
Definition: rosglue.h:14
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ slot_table_avail()

static int slot_table_avail ( IN const nfs41_slot_table table)
static

Definition at line 38 of file nfs41_session.c.

Referenced by init_slot_table(), nfs41_session_free_slot(), nfs41_session_get_slot(), and resize_slot_table().

40 {
41  return table->num_used < table->max_slots;
42 }