Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #32 from hulu/master

[PATCH] randomize the initial rpc xid to avoid reply cache collision
  • Loading branch information...
commit 5ba63317aca8054280b18453790d23a448bdf92c 2 parents 2738507 + a275619
Ronnie Sahlberg authored

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 1 lib/init.c
5 lib/init.c
@@ -25,6 +25,7 @@
25 25 #include <string.h>
26 26 #include <stdlib.h>
27 27 #include <assert.h>
  28 +#include <time.h>
28 29 #include "slist.h"
29 30 #include "libnfs-zdr.h"
30 31 #include "libnfs.h"
@@ -34,6 +35,7 @@
34 35 struct rpc_context *rpc_init_context(void)
35 36 {
36 37 struct rpc_context *rpc;
  38 + static uint32_t salt = 0;
37 39
38 40 rpc = malloc(sizeof(struct rpc_context));
39 41 if (rpc == NULL) {
@@ -59,7 +61,8 @@ struct rpc_context *rpc_init_context(void)
59 61 free(rpc);
60 62 return NULL;
61 63 }
62   - rpc->xid = 1;
  64 + rpc->xid = salt + time(NULL);
  65 + salt += 0x01000000;
63 66 rpc->fd = -1;
64 67
65 68 return rpc;

0 comments on commit 5ba6331

Please sign in to comment.
Something went wrong with that request. Please try again.