mirror of
https://github.com/upa/mscp.git
synced 2026-05-13 22:07:29 +08:00
fix: when msg_fd is 0, use STDOUT_FILENO
This commit is contained in:
@@ -71,6 +71,9 @@ class mscp:
|
|||||||
self.state = STATE_INIT
|
self.state = STATE_INIT
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
if not hasattr(self, "state"):
|
||||||
|
# this instance failed on mscp_init
|
||||||
|
return "mscp:{}:init-failed"
|
||||||
return "mscp:{}:{}".format(self.remote, self.__state2str())
|
return "mscp:{}:{}".format(self.remote, self.__state2str())
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
@@ -194,6 +194,9 @@ static int validate_and_set_defaut_params(struct mscp_opts *o)
|
|||||||
if (o->max_startups == 0)
|
if (o->max_startups == 0)
|
||||||
o->max_startups = DEFAULT_MAX_STARTUPS;
|
o->max_startups = DEFAULT_MAX_STARTUPS;
|
||||||
|
|
||||||
|
if (o->msg_fd == 0)
|
||||||
|
o->msg_fd = STDOUT_FILENO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ static PyObject *wrap_mscp_init(PyObject *sef, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
i->m = mscp_init(remote, direction, &i->mo, &i->so);
|
i->m = mscp_init(remote, direction, &i->mo, &i->so);
|
||||||
if (!i->m) {
|
if (!i->m) {
|
||||||
|
PyErr_Format(PyExc_RuntimeError, "%s", mscp_get_error());
|
||||||
free(i);
|
free(i);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user