Search Results

Search found 3 results on 1 pages for 'selbie'.

Page 1/1 | 1 

  • Wake up thread blocked on accept() call

    - by selbie
    Sockets on Linux question I have a worker thread that is blocked on an accept() call. It simply waits for an incoming network connection, handles it, and then returns to listening for the next connection. When it is time for the program to exit, how do I signal this network worker thread (from the main thread) to return from the accept() call while still being able to gracefully exit its loop and handle it's cleanup code. Some things I tried: 1. pthread_kill to send a signal. Feels kludgy to do this, plus it doesn't reliably allow the thread to do it's shutdown logic. Also makes the program terminate as well. I'd like to avoid signals if at all possible. pthread_cancel. Same as above. It's a harsh kill on the thread. That, and the thread may be doing something else. Closing the listen socket from the main thread in order to make accept() abort. This doesn't reliably work. Some constraints: If the solution involves making the listen socket non-blocking, that is fine. But I don't want to accept a solution that involves the thread waking up via a select call every few seconds to check the exit condition. The thread condition to exit may not be tied to the process exiting. Essentially, the logic I am going for looks like this. void* WorkerThread(void* args) { DoSomeImportantInitialization(); // initialize listen socket and some thread specific stuff while (HasExitConditionBeenSet()==false) { listensize = sizeof(listenaddr); int sock = accept(listensocket, &listenaddr, &listensize); // check if exit condition has been set using thread safe semantics if (HasExitConditionBeenSet()) { break; } if (sock < 0) { printf("accept returned %d (errno==%d)\n", sock, errno); } else { HandleNewNetworkCondition(sock, &listenaddr); } } DoSomeImportantCleanup(); // close listen socket, close connections, cleanup etc.. return NULL; } void SignalHandler(int sig) { printf("Caught CTRL-C\n"); } void NotifyWorkerThreadToExit(pthread_t thread_handle) { // signal thread to exit } int main() { void* ptr_ret= NULL; pthread_t workerthread_handle = 0; pthread_create(&workerthread, NULL, WorkerThread, NULL); signal(SIGINT, SignalHandler); sleep((unsigned int)-1); // sleep until the user hits ctrl-c printf("Returned from sleep call...\n"); SetThreadExitCondition(); // sets global variable with barrier that worker thread checks on // this is the function I'm stalled on writing NotifyWorkerThreadToExit(workerthread_handle); // wait for thread to exit cleanly pthread_join(workerthread_handle, &ptr_ret); DoProcessCleanupStuff(); }

    Read the article

  • Can a member struct be zero-init from the constructor initializer list without calling memset?

    - by selbie
    Let's say I have the following structure declaration (simple struct with no constructor). struct Foo { int x; int y; int z; char szData[DATA_SIZE]; }; Now let's say this struct is a member of a C++ class as follows: class CFoobar { Foo _foo; public: CFoobar(); }; If I declare CFoobar's constructor as follows: CFoobar::CFoobar() { printf("_foo = {%d, %d, %d}\n", _foo.x, _foo.y,_foo.z); for (int x = 0; x < 100; x++) printf("%d\n", _foo.szData[x]); } As you would expect, when CFoobar's constructor runs, garbage data gets printed out Obviously, the easy fix is to memset or ZeroMemory &_foo. It's what I've always done... However, I did notice that if add _foo to the constructor's initialization list with no parameters as follows: CFoobar::CFoobar() : _foo() { That this appears to zero-out the member variables of _foo. At least that was the case with g++ on linux. Now here's my question: Is this standard C++, or is this compiler specific behavior? If it's standard behavior, can someone quote me a reference from an official source? Any "gotchas" in regards to implicit zero-init behavior with more complicated structs and classes?

    Read the article

  • CodePlex Daily Summary for Thursday, May 17, 2012

    CodePlex Daily Summary for Thursday, May 17, 2012Popular ReleasesWatchersNET.UrlShorty: WatchersNET.UrlShorty 01.03.03: changes Fixed Url & Error History when urls contain line breaksAspxCommerce: AspxCommerce1.1: AspxCommerce - 'Flexible and easy eCommerce platform' offers a complete e-Commerce solution that allows you to build and run your fully functional online store in minutes. You can create your storefront; manage the products through categories and subcategories, accept payments through credit cards and ship the ordered products to the customers. We have everything set up for you, so that you can only focus on building your own online store. Note: To login as a superuser, the username and pass...SiteMap Editor for Microsoft Dynamics CRM 2011: SiteMap Editor (1.1.1616.403): BUG FIX Hide save button when Titles or Descriptions element is selectedVisual C++ 2010 Directories Editor: Visual C++ 2010 Directories Editor (x32_x64): release v1.3MapWindow 6 Desktop GIS: MapWindow 6.1.2: Looking for a .Net GIS Map Application?MapWindow 6 Desktop GIS is an open source desktop GIS for Microsoft Windows that is built upon the DotSpatial Library. This release requires .Net 4 (Client Profile). Are you a software developer?Instead of downloading MapWindow for development purposes, get started with with the DotSpatial template. The extensions you create from the template can be loaded in MapWindow.DotSpatial: DotSpatial 1.2: This is a Minor Release. See the changes in the issue tracker. Minimal -- includes DotSpatial core and essential extensions Extended -- includes debugging symbols and additional extensions Tutorials are available. Just want to run the software? End user (non-programmer) version available branded as MapWindow Want to add your own feature? Develop a plugin, using the template and contribute to the extension feed (you can also write extensions that you distribute in other ways). Components ...Mugen Injection: Mugen Injection 2.2.1 (WinRT supported): Added ManagedScopeLifecycle. Increase performance. Added support for resolve 'params'.Microsoft Ajax Minifier: Microsoft Ajax Minifier 4.52: Make preprocessor comment-statements nestable; add the ///#IFNDEF statement. (Discussion #355785) Don't throw an error for old-school JScript event handlers, and don't rename them if they aren't global functions.DotNetNuke® Events: 06.00.00: This is a serious release of Events. DNN 6 form pattern - We have take the full route towards DNN6: most notably the incorporation of the DNN6 form pattern with streamlined UX/UI. We have also tried to change all formatting to a div based structure. A daunting task, since the Events module contains a lot of forms. Roger has done a splendid job by going through all the forms in great detail, replacing all table style layouts into the new DNN6 div class="dnnForm XXX" type of layout with chang...LogicCircuit: LogicCircuit 2.12.5.15: Logic Circuit - is educational software for designing and simulating logic circuits. Intuitive graphical user interface, allows you to create unrestricted circuit hierarchy with multi bit buses, debug circuits behavior with oscilloscope, and navigate running circuits hierarchy. Changes of this versionThis release is fixing one but nasty bug. Two functions XOR and XNOR when used with 3 or more inputs were incorrectly evaluating their results. If you have a circuit that is using these functions...SharpCompress - a fully native C# library for RAR, 7Zip, Zip, Tar, GZip, BZip2: SharpCompress 0.8.1: Two fixes: Rar Decompression bug fixed. Error only occurred on some files Rar Decompression will throw an exception when another volume isn't found but one is expected.?????????? - ????????: All-In-One Code Framework ??? 2012-05-14: http://download.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=1codechs&DownloadId=216140 ???OneCode??????,??????????6????Microsoft OneCode Sample,????2?Data Platform Sample?4?WPF Sample。???????????。 ????,?????。http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=1code&DownloadId=128165 Data Platform Sample CSUseADO CppUseADO WPF Sample CSWPFMasterDetailBinding VBWPFMasterDetailBinding CSWPFThreading VBWPFThreading ....... ???????????blog: http://blog.csd...LINQ to Twitter: LINQ to Twitter Beta v2.0.25: Supports .NET 3.5, .NET 4.0, Silverlight 4.0, Windows Phone 7.1, Client Profile, and Windows 8. 100% Twitter API coverage. Also available via NuGet! Follow @JoeMayo.BlogEngine.NET: BlogEngine.NET 2.6: Get DotNetBlogEngine for 3 Months Free! Click Here for More Info BlogEngine.NET Hosting - 3 months free! Cheap ASP.NET Hosting - $4.95/Month - Click Here!! Click Here for More Info Cheap ASP.NET Hosting - $4.95/Month - Click Here! If you want to set up and start using BlogEngine.NET right away, you should download the Web project. If you want to extend or modify BlogEngine.NET, you should download the source code. If you are upgrading from a previous version of BlogEngine.NET, please take...BlackJumboDog: Ver5.6.2: 2012.05.07 Ver5.6.2 (1) Web???????、????????·????????? (2) Web???????、?????????? COMSPEC PATHEXT WINDIR SERVERADDR SERVERPORT DOCUMENTROOT SERVERADMIN REMOTE_PORT HTTPACCEPTCHRSET HTTPACCEPTLANGUAGE HTTPACCEPTEXCODINGGardens Point Parser Generator: Gardens Point Parser Generator version 1.5.0: ChangesVersion 1.5.0 contains a number of changes. Error messages are now MSBuild and VS-friendly. The default encoding of the *.y file is Unicode, with an automatic fallback to the previous raw-byte interpretation. The /report option has been improved, as has the automaton tracing facility. New facilities are included that allow multiple parsers to share a common token type. A complete change-log is available as a separate documentation file. The source project has been upgraded to Visual...Media Companion: Media Companion 3.502b: It has been a slow week, but this release addresses a couple of recent bugs: Movies Multi-part Movies - Existing .nfo files that differed in name from the first part, were missed and scraped again. Trailers - MC attempted to scrape info for existing trailers. TV Shows Show Scraping - shows available only in the non-default language would not show up in the main browser. The correct language can now be selected using the TV Show Selector for a single show. General Will no longer prompt for ...NewLife XCode ??????: XCode v8.5.2012.0508、XCoder v4.7.2012.0320: X????: 1,????For .Net 4.0?? XCoder????: 1,???????,????X????,?????? XCode????: 1,Insert/Update/Delete???????????????,???SQL???? 2,IEntityOperate?????? 3,????????IEntityTree 4,????????????????? 5,?????????? 6,??????????????Google Book Downloader: Google Books Downloader Lite 1.0: Google Books Downloader Lite 1.0Python Tools for Visual Studio: 1.5 Alpha: We’re pleased to announce the release of Python Tools for Visual Studio 1.5 Alpha. Python Tools for Visual Studio (PTVS) is an open-source plug-in for Visual Studio which supports programming with the Python language. PTVS supports a broad range of features including: • Supports Cpython, IronPython, Jython and Pypy • Python editor with advanced member, signature intellisense and refactoring • Code navigation: “Find all refs”, goto definition, and object browser • Local and remote debugging...New ProjectsAmlak: Amlak projectApparat: An Open Source Game/Simulation Engine made with C# and SlimDX.CarShop emulator: carshopDynaMaxx Server Backend: DynaMaxx Server BackendEntry-Level C# Password Generator: The Entry-Level C# Password Generator is a piece of software written for two purposes. To be kept as simple as possible for newcomers to the langauge to understand how to use the language and to help people make a new secure password for themselves.faccipractica: ESTA ES LA CAPA DE DATOSFACCIULEAM: ESTE ES UN PROYECTO DE PRACTICAFast C++ Math Expression Parser: The C++ Mathematical Expression Library (ExprTk) is a simple to use, easy to integrate and extremely efficient and fast mathematical expression parsing and evaluation engine. The parsing engine supports various kinds of functional and logic processing semantics and is very easily extendible.Font Data Catalog: A tool to store font dataGraffiti: Graffiti is a high-performance rendering engine built specifically for the Reach profile on top of XNA/Monogame with a very specific feature set * Support for the Reach profile * CPU/GPU vertex transformation (using SkinnedEffect) * Quake 3 shader style effects (Multi-pass) for anything Graffiti can render * Keyframed/procedural animation framework * Primitive rendering (antialiased, variable-sized points and lines) * Particle system using complex/primitive objects *Text rendering (w...homeland: A simple form Engine for Rails app.HTML5 for SharePoint 2010: HTML5 for SharePoint 2010 is a package of controls and webparts that allows using HTML5 controls in SharePoint. Image Cropper 4 Umbraco 5: Image cropper for Umbraco 5.IPickMovies: This is project for IPick Movies from Mezanmi Technologies.JFrame: jframeJustForTest: For Testkxcxw: This is a website project. Latence: projectLive: this is Live project.MASMYTEST: fdfMP3 player: Project for MUL.MSI Validation: MSI ValidationMyWp: wp applicationOpen Waves Activity Feed: Activity Feed component to be used in ASP.NET projects based on EPiServer CMS, SP, and other.pComboBox: Script ComboBox - Initial versions complete and functional ( current version is 1.54) program and documentation available on justcode.ca - http://www.justcode.ca/justwindowscode/ Source will be available at pcombobox.codeplex.com The basic functionality is shown in the below batch file to call this combobox was coded as follows pcombobox /p:one,"# two",three,4 /t:"title" echo %ERRORLEVEL% Basically you can call this combobox dialog window from a batch file or a vbscript an...Periodic.Net: Periodic.Net is a Periodic Table layout for Windows based on WPF and the .Net Framework 3.5 SP1, More info coming soon.Pob-Pong: A simple Pong game - the first Project of Elsor and Zakk.PodcastCasting: Podcast casting system for Podcasters that use voice talents in their storiesresolvendo.net: Projeto desenvolvido na 3 etapa do S2BSharepoint for TFS: Custom control to integrate files from Sharepoint to TFSShutdownAB: Windows service to shutdown computer after a backup.SSIS Restart Framework: A framework that provides restartability for SSIS 2012 projects. It is very much work in progress so at the current time, use at your own peril.Standalone Encrypted Sign In Library: The ECL library is a standalone connection library !stunserver: New version 1.1. This is the source code to STUNTMAN - an open source STUN server and client code by john selbie. Compliant with the latest RFCs including 5389, 5769, and 5780. Also includes backwards compatibility for RFC 3489. The stun server code is part of a larger personal project involving P2P file sharing and NAT traversal. Version 1.1 compiles on Linux, MacOS, BSD, and Solaris. Additional features are in development. www.stunprotocol.orgTask Scheduler Assistant: This is a very simple Windows service that watches folders/files and triggers an associated Scheduled Task accordingly. A simple * wildcard scheme is used for file triggers. Wildcards can only be in the filename and not in the path. This was initially built to be a Task Scheduler trigger from import processes from clients, providing the missing Trigger type from Window's Task Scheduler.Tech4WPF: Tech4WPF make it easier for developers to create technical applications. You will no longer have to create your own user controlls like knobs, gauges and simple charts. It's developed in C#/WPF. This project was inspirated by Qwt - Qt Widgets for Technical Applications http://qwt.sourceforge.net/. It's not port, but similar project, creating controls for technical aplications using .NET framework, WPF and all benefits of this platform like binding etc. Tech4WPF was created as a bachelo...TestProject_Git: git projectVS Templates for generating Duet Workspace sites: This project provides VS templates to easily create Duet Enterprise workspace sites.WinTest: This is a winform application. It need net framework 3.5 or higher version.WPF Progressive FizzBuzz Coding Assignment: Classic "FizzBuzz".YahalomProject: YahalomProject is for testing and using codeplex , tfs...Zorbo: Zorbo Server library was designed to add a unique twist to the Ares Galaxy P2P community. It features a large and detailed plugin architecture that allows developers to create rich chatroom experiences while being light-weight and fast.

    Read the article

1