Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netopeer-agent 100% CPU usage after "edit-config: Unknown error occurred." #244

Open
SeanCondon opened this issue Dec 2, 2016 · 0 comments

Comments

@SeanCondon
Copy link

Hi - just FYI

I had a problem with calling edit-config from netopeer-cli when passing a large config (76k) through dropbear.

Dropbear has a default chunk size of 24kB and so the message was getting split up. Somehow this causes an error in a file descriptor I think between dropbear and the netopeer-agent. When I close the client the CPU usage of netopeer-agent goes to 100%.

I don't know what causes the first problem, but the 100% problem is cause in the file libnetconf/src/session.c int nc_session_read_len(..)

Starting on line 1644 (with libnetconf 0.9.1, line 1658 with libnetconf 0.10.0), I added in the condition } else if (c == 0) { and it stops the process going to 100% and now it exits the client cleanly:

	if (session->fd_input != -1) {
			/* read via file descriptor */
			c = read (session->fd_input, &(buf[rd]), chunk_length - rd);
			if (c == -1) {
				if (errno == EAGAIN) {
					usleep (NC_READ_SLEEP);
					continue;
				} else {
					ERROR("Reading from an input file descriptor failed (%s)", strerror(errno));
					free (buf);
					*len = 0;
					*text = NULL;
					return (EXIT_FAILURE);
				}
			} else if (c == 0) {
				ERROR("Reading from an input file descriptor failed (%s) c=0, fd closed unexpectedly.", strerror(errno));
				free (buf);
				*len = 0;
				*text = NULL;
				return (EXIT_FAILURE);
			}
		} ....

To solve the other problem, I increased the dropbear window size to 512kB, with the -W option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant