summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2011-08-17 20:15:02 +0000
committerErmal <eri@pfsense.org>2011-08-17 20:15:02 +0000
commite15e9c6b671a3a07063da769cb334d1570bd4365 (patch)
treeeaab09c52348102b19edd60c6ea131ac5cfe523a /etc
parent8e95a671fae38d133247cfe2f3b163a9a76debda (diff)
downloadpfsense-e15e9c6b671a3a07063da769cb334d1570bd4365.zip
pfsense-e15e9c6b671a3a07063da769cb334d1570bd4365.tar.gz
Ticket #1279. Decrease the refcount even though we're in booting phase. This helps the refcount to work as intended and help in making filesystem read only correctly on embedded platfroms. While here put some exceptions to refcount API and silent any related errors that might trigger. Also take not of the NOTE on the php manual that after a share memory is opened further references to it for size and access mode should be 0.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/config.lib.inc4
-rw-r--r--etc/inc/util.inc54
2 files changed, 33 insertions, 25 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index 9ac40c9..05465c3 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -348,10 +348,10 @@ function conf_mount_ro() {
if($platform == "cdrom" or $platform == "pfSense")
return;
- if($g['booting'])
+ if (refcount_unreference(1000) > 0)
return;
- if (refcount_unreference(1000) > 0)
+ if($g['booting'])
return;
clear_subsystem_dirty('mount');
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 94f1205..fee252c 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -179,37 +179,45 @@ function send_multiple_events($cmds) {
}
function refcount_init($reference) {
- $shmid = shmop_open($reference, "c", 0644, 10);
- shmop_write($shmid, 0, 0);
- shmop_close($shmid);
+ $shmid = @shmop_open($reference, "c", 0644, 10);
+ @shmop_write($shmid, 0, 0);
+ @shmop_close($shmid);
}
function refcount_reference($reference) {
- $shmid = @shmop_open($reference, "w", 0644, 10);
- if (!$shmid) {
- refcount_init($reference);
- $shmid = shmop_open($reference, "w", 0644, 10);
+ try {
+ $shmid = @shmop_open($reference, "w", 0644, 10);
+ if (!$shmid) {
+ refcount_init($reference);
+ $shmid = @shmop_open($reference, "w", 0, 0);
+ }
+ $shm_data = @shmop_read($shmid, 0, 10);
+ $shm_data = intval($shm_data) + 1;
+ @shmop_write($shmid, $shm_data, 0);
+ @shmop_close($shmid);
+ } catch (Exception $e) {
+ log_error($e->getMessage());
}
- $shm_data = shmop_read($shmid, 0, 10);
- $shm_data = intval($shm_data) + 1;
- shmop_write($shmid, $shm_data, 0);
- shmop_close($shmid);
-
+
return $shm_data;
}
function refcount_unreference($reference) {
- /* We assume that the shared memory exists. */
- $shmid = shmop_open($reference, "w", 0644, 10);
- $shm_data = shmop_read($shmid, 0, 10);
- $shm_data = intval($shm_data) - 1;
- if ($shm_data < 0) {
- //debug_backtrace();
- log_error(sprintf(gettext("Reference %s is going negative, not doing unreference."), $reference));
- } else
- shmop_write($shmid, $shm_data, 0);
- shmop_close($shmid);
-
+ try {
+ /* We assume that the shared memory exists. */
+ $shmid = @shmop_open($reference, "w", 0, 0);
+ $shm_data = @shmop_read($shmid, 0, 10);
+ $shm_data = intval($shm_data) - 1;
+ if ($shm_data < 0) {
+ //debug_backtrace();
+ log_error(sprintf(gettext("Reference %s is going negative, not doing unreference."), $reference));
+ } else
+ @shmop_write($shmid, $shm_data, 0);
+ @shmop_close($shmid);
+ } catch (Exception $e) {
+ log_error($e->getMessage());
+ }
+
return $shm_data;
}
OpenPOWER on IntegriCloud