aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2024-03-19 20:35:35 +0100
committerHarald Welte <laforge@osmocom.org>2024-03-19 20:43:25 +0100
commite3bf74974785303c7c7e84c90cc828e1594be685 (patch)
treeb6487fc7cefba7c4844ceeb152496c1de4ef9b87
parent81b3579d7230ba08381f77d83aa394675ae89433 (diff)
HACK: Try to debug osmo_io based logging not workinglaforge/log_io_stderr
-rw-r--r--src/core/logging.c8
-rw-r--r--src/core/osmo_io.c15
2 files changed, 19 insertions, 4 deletions
diff --git a/src/core/logging.c b/src/core/logging.c
index a10131e1..1588aafd 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -968,6 +968,7 @@ static void _file_raw_output(struct log_target *target, int subsys, unsigned int
rc = _output_buf((char *)msgb_data(msg), msgb_tailroom(msg), target, subsys, level, file, line, cont, format, ap);
msgb_put(msg, rc);
+ printf("writing msgb");
rc = osmo_iofd_write_msgb(target->tgt_file.iofd, msg);
if (rc < 0)
msgb_free(msg);
@@ -1121,6 +1122,7 @@ int log_target_file_switch_to_wqueue(struct log_target *target)
struct osmo_io_fd *iofd;
const char *name;
int rc;
+ printf("%s\n", __func__);
if (!target)
return -ENODEV;
@@ -1146,8 +1148,10 @@ int log_target_file_switch_to_wqueue(struct log_target *target)
osmo_wqueue_init(wq, LOG_WQUEUE_LEN);
#endif
iofd = osmo_iofd_setup(target, -1, name, OSMO_IO_FD_MODE_READ_WRITE, &log_file_ioops, target);
- if (!iofd)
+ if (!iofd) {
+ printf("unable to setup");
return -ENOMEM;
+ }
osmo_iofd_set_txqueue_max_length(iofd, LOG_WQUEUE_LEN);
fflush(target->tgt_file.out);
@@ -1156,12 +1160,14 @@ int log_target_file_switch_to_wqueue(struct log_target *target)
else
rc = dup(STDERR_FILENO);
if (rc < 0) {
+ printf("unable to open");
osmo_iofd_free(iofd);
return -errno;
}
rc = osmo_iofd_register(iofd, rc);
if (rc < 0) {
+ printf("unable to register");
osmo_iofd_free(iofd);
return -EIO;
}
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index b589cb71..175a666c 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -209,14 +209,18 @@ struct msgb *iofd_msgb_pending_or_alloc(struct osmo_io_fd *iofd)
*/
int iofd_txqueue_enqueue(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr)
{
- if (iofd->tx_queue.current_length >= iofd->tx_queue.max_length)
+ if (iofd->tx_queue.current_length >= iofd->tx_queue.max_length) {
+ printf("ENOSPC");
return -ENOSPC;
+ }
llist_add_tail(&msghdr->list, &iofd->tx_queue.msg_queue);
iofd->tx_queue.current_length++;
- if (iofd->tx_queue.current_length == 1 && !IOFD_FLAG_ISSET(iofd, IOFD_FLAG_CLOSED))
+ if (iofd->tx_queue.current_length == 1 && !IOFD_FLAG_ISSET(iofd, IOFD_FLAG_CLOSED)) {
+ printf("===== ENABLE\n");
osmo_iofd_ops.write_enable(iofd);
+ }
return 0;
}
@@ -435,17 +439,21 @@ void iofd_handle_send_completion(struct osmo_io_fd *iofd, int rc, struct iofd_ms
int osmo_iofd_write_msgb(struct osmo_io_fd *iofd, struct msgb *msg)
{
int rc;
+ printf("%s\n", __func__);
if (OSMO_UNLIKELY(msgb_length(msg) == 0)) {
LOGPIO(iofd, LOGL_ERROR, "Length is 0, rejecting msgb.\n");
+ printf("%s: EINVAL\n", __func__);
return -EINVAL;
}
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_READ_WRITE);
struct iofd_msghdr *msghdr = iofd_msghdr_alloc(iofd, IOFD_ACT_WRITE, msg, 0);
- if (!msghdr)
+ if (!msghdr) {
+ printf("%s: ENOMEM\n", __func__);
return -ENOMEM;
+ }
msghdr->flags = MSG_NOSIGNAL;
msghdr->iov[0].iov_base = msgb_data(msghdr->msg);
@@ -456,6 +464,7 @@ int osmo_iofd_write_msgb(struct osmo_io_fd *iofd, struct msgb *msg)
rc = iofd_txqueue_enqueue(iofd, msghdr);
if (rc < 0) {
iofd_msghdr_free(msghdr);
+ printf("%s: ERRENQ\n", __func__);
LOGPIO(iofd, LOGL_ERROR, "enqueueing message failed (%d). Rejecting msgb\n", rc);
return rc;
}