Skip to contentSkip to conversation

Fix socket fd allocation on -rc3

PATCH New Dan Smith 1 participant 1 message Feb 9, 2010 Networking

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Fix socket fd allocation on -rc3

Since the core socket functions expect to allocate an fd when they allocate the file, we need to be sure to release that file descriptor so that the core checkpoint file code can properly allocate it for us. The core socket function doesn't actually map the file and the fd together, so we just have to release it once we get it.

Also, remove the #if 0 around the sock_hold() which was preventing the refcount from being correct (and thus causing a premature socket closure during restart).

---
 net/checkpoint.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
net/checkpoint.c +2 -6
index 69a0a76..c6b6341 100644
@@ -975,17 +975,13 @@ struct file *sock_file_restore(struct ckpt_ctx *ctx, struct ckpt_hdr_file *ptr)
 	fd = sock_alloc_file(sk->sk_socket, &file, O_RDWR);
 	if (fd < 0)
 		return ERR_PTR(fd);
+	put_unused_fd(fd); /* We'll let the checkpoint code re-allocate this */
 
-#if 0
 	/* Since objhash assumes the initial reference for a socket,
 	 * we bump it here for this descriptor, unlike other places in
 	 * the socket code which assume the descriptor is the owner.
 	 */
-	sock_hold(sock->sk);
-#endif
-
-	get_file(file);
-	sys_close(fd);
+	sock_hold(sk);
 
 	ret = restore_file_common(ctx, file, ptr);
 	if (ret < 0) {
Signature · 1 line
1.6.2.5