Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 153906 Details for
Bug 226997
udevd read buffer too small.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch modifies how /proc/stat is processed.
patch (text/plain), 2.29 KB, created by
George Beshers
on 2007-05-01 23:49:52 UTC
(
hide
)
Description:
Patch modifies how /proc/stat is processed.
Filename:
MIME Type:
Creator:
George Beshers
Created:
2007-05-01 23:49:52 UTC
Size:
2.29 KB
patch
obsolete
>diff -Naur udev-110.Orig/udevd.c udev-110.new/udevd.c >--- udev-110.Orig/udevd.c 2007-05-01 08:33:39.000000000 -0400 >+++ udev-110.new/udevd.c 2007-05-01 12:49:38.000000000 -0400 >@@ -347,31 +347,21 @@ > > static int cpu_count(void) > { >- int f; >- char buf[65536]; >+ FILE* f; >+ char buf[1024]; > int len; > const char *pos; > int count = 0; > >- f = open("/proc/stat", O_RDONLY); >- if (f == -1) >+ f = fopen("/proc/stat", "r"); >+ if (f == NULL) > return -1; > >- len = read(f, buf, sizeof(buf)-1); >- close(f); >- if (len <= 0) >- return -1; >- buf[len] = '\0'; >- >- pos = strstr(buf, "cpu"); >- if (pos == NULL) >- return -1; >- >- while (pos != NULL) { >- if (strncmp(pos, "cpu", 3) == 0 &&isdigit(pos[3])) >+ while (fgets(buf, 1024, f) != NULL) { >+ if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3])) > count++; >- pos = strstr(&pos[3], "cpu"); > } >+ fclose(f); > > if (count == 0) > return -1; >@@ -380,30 +370,46 @@ > > static int running_processes(void) > { >- int f; >- char buf[32768]; >+ FILE* f; >+ char buf[1024]; > int len; >- int running; >+ int running = -1; > const char *pos; >+ int retries = 3; > >- f = open("/proc/stat", O_RDONLY); >- if (f == -1) >- return -1; >- >- len = read(f, buf, sizeof(buf)-1); >- close(f); >- if (len <= 0) >- return -1; >- buf[len] = '\0'; >- >- pos = strstr(buf, "procs_running "); >- if (pos == NULL) >- return -1; >+ /* >+ * The retries is probably overkill but the text display is >+ * changing rapidly.on large systems (>= 512p) and so, while >+ * I have not actually recorded an instance where the retry >+ * was used I would rather not have it fail. >+ * >+ * An alternative approach would be to note when we are on >+ * a fairly large system (8cpus and 16Gbytes say) at which >+ * point throttling is probably not really necessary. >+ */ >+ do { >+ f = fopen("/proc/stat", "r"); >+ if (f == NULL) >+ return -1; >+ >+ while (fgets(buf, 1024, f) != NULL) { >+ pos = strstr(buf, "procs_running "); >+ if (pos != NULL) { >+ int res; >+ res = sscanf(pos, "procs_running %u", >+ &running); >+ if (res == 1) { >+ fclose(f); >+ return running; >+ } >+ break; >+ } >+ } > >- if (sscanf(pos, "procs_running %u", &running) != 1) >- return -1; >+ fclose(f); >+ } while (retries-- > 0); > >- return running; >+ return -1; > } > > /* return the number of process es in our session, count only until limit */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 226997
:
149299
|
153906
|
154301
|
156355