---
name: "wq_has_sleeper"
section: "9"
platform: "linux"
package: "linux-manual-3.16"
version: "3.16.56-1+deb8u1"
release: "Debian 8 (Jessie)"
platforms: ["linux"]
url: "https://new.carta.tech/wq_has_sleeper"
---

# wq\_has\_sleeper(9)

check if there are any waiting processes

## NAME

wq\_has\_sleeper - check if there are any waiting processes

## SYNOPSIS

**bool wq\_has\_sleeper(struct socket\_wq \*** *wq***);**

## ARGUMENTS

*wq*

struct socket\_wq

## DESCRIPTION

Returns true if socket\_wq has waiting processes

The purpose of the wq\_has\_sleeper and sock\_poll\_wait is to wrap the memory barrier call. They were added due to the race found within the tcp code.

## CONSIDER FOLLOWING TCP CODE PATHS

CPU1 CPU2

sys\_select receive packet ... ... \_\_add\_wait\_queue update tp-\>rcv\_nxt ... ... tp-\>rcv\_nxt check sock\_def\_readable ... { schedule **rcu\_read\_lock**; wq = rcu\_dereference(sk-\>sk\_wq); if (wq && waitqueue\_active(wq-\>wait)) wake\_up\_interruptible(wq-\>wait) ... }

The race for tcp fires when the \_\_add\_wait\_queue changes done by CPU1 stay in its cache, and so does the tp-\>rcv\_nxt update on CPU2 side. The CPU1 could then endup calling schedule and sleep forever if there are no more data on the socket.

## COPYRIGHT
