changeset: 7215:dfdc2967c410
user: Anders Widell <a...@..son.com>
date: Thu Jan 07 12:26:07 2016 +0100
summary: base: Add missing #ifdef around _GNU_SOURCE macro definition [#777]
changeset: 7216:6d4618d74176
user: Anders Widell <a...@..son.com>
date: Thu Jan 07 12:26:13 2016 +0100
summary: base: Simplify osaf_nanosleep() and add new time constants [#777]
changeset: 7217:ebe0c7f64182
tag: tip
user: Anders Widell <a...@..son.com>
date: Thu Jan 07 12:26:51 2016 +0100
summary: base: Add unit tests for osaf_time.c [#777]
[staging:dfdc29]
[staging:6d4618]
[staging:ebe0c7]
---
** [tickets:#777] base: Add more glibc wrapper functions with error handling**
**Status:** review
**Milestone:** 5.0.FC
**Created:** Mon Feb 10, 2014 02:20 PM UTC by Anders Widell
**Last Updated:** Tue Dec 22, 2015 04:12 PM UTC
**Owner:** Anders Widell
This is a generic ticket for adding more convenience/utility functions to BASE.
The generic strategy is to add utility functions with the same name as the
corresponding glibc function, but with an osaf_ prefix. The utility functions
will have the following added value:
* For errno == EINTR, it will try the function again in a loop (only in the
case if EINTR is a possible result of the function according the the manual
page). Also note the important exception that the close() function shall NOT
have a loop when it returns EINTR (it's a fairly common mistake to implement
such a loop for close()).
* For errors that can only happen due to a bug in the program itself (e.g.
EFAULT, EINVAL, EBADF, EMFILE etc), call osaf_abort() to generate a core dump.
* For out-of-system-resources errors (ENOMEM, ENFILE etc), typically log a
message and terminate the process. We should not generate a core-dump, since
it's (probably) not a bug in the process itself (of course it could be, if it
is the one leaking memory). Still there is not much we can do if the system has
run out of memory or file descriptors so all we can do is exit.
* For run-time erros that can happen and do not necessarily mean there is a bug
(ECONNREFUSED, ENETUNREACH, ETIMEDOUT etc), typically log the error and return
-1 to let the caller handle the error. Logging in this case should be done with
care, if it is something that can happen often. One possibility is to only log
into a ring-buffer in the process' own memory, that can be inspected in a core
dump. Or we could have some kind of suppression mechanism to avoid filling up
the log files.
By using such utility functions, the program code can be made simpler. We don't
need to have loops checking for EINTR everywhere, and in many cases these
wrapper functions can be made so that they can never fail (meaning that the
process is terminated in such a case, and the function doesn't return to the
caller).
---
Sent from sourceforge.net because opensaf-tickets@lists.sourceforge.net is
subscribed to https://sourceforge.net/p/opensaf/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://sourceforge.net/p/opensaf/admin/tickets/options. Or, if this is a
mailing list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
_______________________________________________
Opensaf-tickets mailing list
Opensaf-tickets@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets