[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone: c14cb021dafa331f859634a1408
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone: c14cb021dafa331f859634a14087f6f81d870aed |
Date: |
Tue, 27 Mar 2012 20:17:46 +0200 (CEST) |
revision: c14cb021dafa331f859634a14087f6f81d870aed
date: 2012-03-27T18:17:15
author: Richard Levitte <address@hidden>
branch: net.venge.monotone
changelog:
Change the use of getcwd() to a more dynamic way.
BIG FAT WARNING: THIS CODE IS NOT TESTED! The reason is that it will
never be reached until monotone starts using AF_LOCAL sockets.
This changed was purely to have monotone compilable on platforms where
MAXPATHLEN isn't defined, such as GNU/Hurd.
manifest:
format_version "1"
new_manifest [b1011234bbb1c39b247a25ba4b92bce6cd8e6891]
old_revision [abed170b1da27108dc8dc5fb33729e3e9270f6f6]
patch "src/netxx/serverbase.cxx"
from [7a9b465ce4b0b02cb8ff126acf86d3896b4eb456]
to [156f2090341d2a36bdb718e7c69df58f9251983e]
============================================================
--- src/netxx/serverbase.cxx 7a9b465ce4b0b02cb8ff126acf86d3896b4eb456
+++ src/netxx/serverbase.cxx 156f2090341d2a36bdb718e7c69df58f9251983e
@@ -44,6 +44,8 @@
#include "probeinfo.h"
#include "socket.h"
+#include <cerrno>
+
// standard includes
#include <map>
#include <vector>
@@ -167,13 +169,26 @@ void Netxx::ServerBase::bind_to(const Ad
if (saun->sun_path[0] == '/') {
files_.push_back(saun->sun_path);
} else {
- char buffer[MAXPATHLEN];
+ // BIG FAT WARNING: THIS CODE HAS NOT BEEN TESTED!
+ // The original code is non-dynamic, depending on
+ // the value of MAXPATHLEN. Since that macro isn't
+ // guaranteed to exist, a more dynamic use if getcwd()
+ // was written. However, since monotone doesn't use
+ // AF_LOCAL sockets, this code will not be reached.
+ int e = ERANGE;
+ int n = 4096;
- if (getcwd(buffer, sizeof(buffer))) {
- std::string fullpath = buffer; fullpath += '/'; fullpath += saun->sun_path;
- files_.push_back(fullpath);
- } else {
- files_.push_back(saun->sun_path);
+ while (e == ERANGE) {
+ char buffer[n];
+ e = 0;
+ n += 4096;
+
+ if (getcwd(buffer, n)) {
+ std::string fullpath = buffer; fullpath += '/'; fullpath += saun->sun_path;
+ files_.push_back(fullpath);
+ } else if ((e = errno) != ERANGE) {
+ files_.push_back(saun->sun_path);
+ }
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone: c14cb021dafa331f859634a14087f6f81d870aed,
code <=