Remove unused code
This commit is contained in:
parent
25cb73511f
commit
a410d38966
3 changed files with 0 additions and 49 deletions
|
|
@ -2042,28 +2042,8 @@ send_data_to_peer(PyObject *self UNUSED, PyObject *args) {
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
random_unix_socket(PyObject *self UNUSED, PyObject *args UNUSED) {
|
||||
#ifndef SO_PASSCRED
|
||||
errno = ENOTSUP;
|
||||
return PyErr_SetFromErrno(PyExc_OSError);
|
||||
#else
|
||||
int fd, optval = 1;
|
||||
struct sockaddr_un bind_addr = {.sun_family=AF_UNIX};
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) return PyErr_SetFromErrno(PyExc_OSError);
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof optval) != 0) goto fail;
|
||||
if (bind(fd, (struct sockaddr *)&bind_addr, sizeof(sa_family_t)) != 0) goto fail;
|
||||
return PyLong_FromLong((long)fd);
|
||||
fail:
|
||||
safe_close(fd, __FILE__, __LINE__);
|
||||
return PyErr_SetFromErrno(PyExc_OSError);
|
||||
#endif
|
||||
}
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
METHODB(safe_pipe, METH_VARARGS),
|
||||
METHODB(random_unix_socket, METH_NOARGS),
|
||||
{"add_timer", (PyCFunction)add_python_timer, METH_VARARGS, ""},
|
||||
{"remove_timer", (PyCFunction)remove_python_timer, METH_VARARGS, ""},
|
||||
METHODB(monitor_pid, METH_VARARGS),
|
||||
|
|
|
|||
|
|
@ -1591,10 +1591,6 @@ def sigqueue(pid: int, signal: int, value: int) -> None:
|
|||
pass
|
||||
|
||||
|
||||
def random_unix_socket() -> int:
|
||||
pass
|
||||
|
||||
|
||||
def read_signals(fd: int, callback: Callable[[SignalInfo], None]) -> None:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -383,31 +383,6 @@ def unix_socket_paths(name: str, ext: str = '.lock') -> Generator[str, None, Non
|
|||
yield os.path.join(loc, filename)
|
||||
|
||||
|
||||
def random_unix_socket() -> 'Socket':
|
||||
import shutil
|
||||
import socket
|
||||
import stat
|
||||
import tempfile
|
||||
|
||||
from kitty.fast_data_types import random_unix_socket as rus
|
||||
try:
|
||||
fd = rus()
|
||||
except OSError:
|
||||
for path in unix_socket_directories():
|
||||
ans = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)
|
||||
tdir = tempfile.mkdtemp(prefix='.kitty-', dir=path)
|
||||
atexit.register(remove_socket_file, ans, tdir, shutil.rmtree)
|
||||
path = os.path.join(tdir, 's')
|
||||
ans.bind(path)
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
|
||||
break
|
||||
else:
|
||||
ans = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0, fileno=fd)
|
||||
ans.set_inheritable(False)
|
||||
ans.setblocking(False)
|
||||
return ans
|
||||
|
||||
|
||||
def parse_address_spec(spec: str) -> tuple[AddressFamily, Union[tuple[str, int], str], Optional[str]]:
|
||||
import socket
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue