Overpass API developpement

Text archives Help


[overpass] Re: Sockaddr on OS X (was Re: Re: Where is bin/init_osm3s.sh?)


Chronological Thread 
  • From: mmd <mmd.osm@gmail.com>
  • To: overpass@osm101.openstreetmap.fr
  • Subject: [overpass] Re: Sockaddr on OS X (was Re: Re: Where is bin/init_osm3s.sh?)
  • Date: Mon, 15 Jun 2015 20:12:04 +0200

Am 13.06.2015 um 16:34 schrieb Malcolm Herring:
> On 13 Jun 2015, at 15:10, Roland Olbricht <roland.olbricht@gmx.de> wrote:
>>
>> Thank you. Please try these two files. They should add extra debug output
>> (in particular string lengths).
>
> imac:osm-3s_v0.7.52 mherring$ bin/dispatcher --osm-base --meta --db-dir="db"
> C /Users/mherring/osm-3s_v0.7.52/db//osm3s_v0.7.52_osm_base 57
> :
> D /Users/mherring/osm-3s_v0.7.52/db//osm3s_v0.7.52_osm_base 57
>
> File_Error No such file or directory 2
> /Users/mherring/osm-3s_v0.7.52/db//osm3s_v0.7.52_osm_base
> Dispatcher_Server::8
>
>

Some additional pointers:

http://idletechnology.blogspot.de/2011/12/unix-domain-sockets-on-osx.html
http://stackoverflow.com/questions/2307511/proper-length-of-an-af-unix-socket-when-calling-bind

Take particular note of the use of a macro SUN_LEN (non-portable, Mac
OS-only).

Based on both posts, I would do the following three changes to
dispatcher.cc:

(1) Different size calculation
(2) Unlink added to remove old file (this might be optional).
(3) Use SUN_LEN macro instead
(#ifdef __APPLE__ needs to be added later, if this all works)


Before:
-------

struct sockaddr_un local;
local.sun_family = AF_UNIX;
strcpy(local.sun_path, socket_name.c_str());
#ifdef __APPLE__
local.sun_len = socket_name.size() + 1; // << (1)

std::cerr<<"C\t"<<socket_name<<'\t'<<socket_name.size()<<'\t'<<local.sun_len<<'\n';
#endif
std::cerr<<"D\t"<<socket_name<<'\t'<<socket_name.size()<<'\t'<<'\n';
// << (2)
if (bind(socket_descriptor, (struct sockaddr*)&local,
sizeof(local.sun_family) + strlen(local.sun_path)) == -1) //<< (3)
throw File_Error
(errno, socket_name, "Dispatcher_Server::4");
if (chmod(socket_name.c_str(), S_666) == -1)
throw File_Error
(errno, socket_name, "Dispatcher_Server::8");


After:
------

struct sockaddr_un local;
local.sun_family = AF_UNIX;
strcpy(local.sun_path, socket_name.c_str());
#ifdef __APPLE__
local.sun_len = sizeof(local);

std::cerr<<"C\t"<<socket_name<<'\t'<<socket_name.size()<<'\t'<<local.sun_len<<'\n';
#endif
std::cerr<<"D\t"<<socket_name<<'\t'<<socket_name.size()<<'\t'<<'\n';
unlink(local.sun_path);
if (bind(socket_descriptor, (struct sockaddr*)&local,
SUN_LEN(&local)) == -1)
throw File_Error
(errno, socket_name, "Dispatcher_Server::4");
if (chmod(socket_name.c_str(), S_666) == -1)
throw File_Error
(errno, socket_name, "Dispatcher_Server::8");


This is completely untested, though.

Cheers
mmd












Archive powered by MHonArc 2.6.18.

Top of page