小编rub*_*o77的帖子

调用stop()和析构函数后仍然提供Poco HTTPServer连接

我使用Poco :: HTTPServer时遇到问题.正如在TCPServer的文档中所描述的那样:

调用stop()后,不会接受任何新连接,并且将丢弃所有排队连接.但是,已经提供服务的连接将继续提供服务.

每个连接都在自己的线程中执行.虽然似乎析构函数被成功地称为连接线程仍然存在并且提供连接,这导致分段错误.

我想取消所有连接.因此,我Poco::ThreadPool::defaultPool().stopAll();在我的服务器类的析构函数中使用,这导致了ThreadPool文档中描述的行为(它需要10秒,对象不会被删除):

如果一个线程在10秒内未能停止(例如由于编程错误),则不会删除底层线程对象,并且此方法仍会返回.这允许在行为不当线程的情况下或多或少地正常关闭.

我的问题是:我如何实现更优雅的方式?Poco库中是否存在编程错误?

编辑:我使用GNU/Linux(Ubuntu 10.04)和eclipse + cdt作为IDE,目标系统是嵌入式Linux(内核2.6.9).在两个系统上,我都经历了所描述的行为

我正在处理的应用程序应通过Web界面进行配置.因此服务器发送一个事件(在上传新配置时)到main重启.

这是大纲:

main{
    while (true){
        server = new Server(...);
        server->start();
        // wait for termination request
        server->stop();
        delete server;
    }
}

class Server{
    Poco:HTTPServer m_Server;

    Server(...):
         m_Server(requestHandlerFactory, socket, params);
    {
    }

    ~Server(){
         [...]
         Poco::ThreadPool::defaultPool().stopAll(); // This takes 10 seconds!
         // without the above line I get segmentation faults, 
         // because connections are still being served. 
    }

    start() { m_Server.start(); }
    stop() { m_Server.stop(); }
}
Run Code Online (Sandbox Code Playgroud)

c++ linux multithreading poco-libraries

4
推荐指数
1
解决办法
2689
查看次数

如何用PHP将GPS坐标转换为完整的地址?

我在表格中有GPS坐标54.1456123 10.413456.

如何使用PHP将它们转换为包含邮政编码,街道和城市的地址?

php gps google-maps-api-3

4
推荐指数
2
解决办法
1万
查看次数

从places.sqlite 文件中恢复书签

我在使用 Firefox 中的标准导出功能将 Firefox 中的数千个书签导出到 HTML 文件时遇到问题。我收到此错误:

*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: root is undefined
Full stack: BookmarkExporter@resource://gre/modules/BookmarkHTMLUtils.jsm:980:1
BHU_exportToFile/<@resource://gre/modules/BookmarkHTMLUtils.jsm:228:22
TaskImpl_run@resource://gre/modules/Task.jsm:314:40
Handler.prototype.process@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:865:23
this.PromiseWalker.walkerLoop@resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js:744:7

************************* 
Run Code Online (Sandbox Code Playgroud)

https://gist.github.com/rubo77/12ef9be4060c7935c74c

有没有办法在控制台上导出我的书签,以便我可以将它们导入到新的 firefox 配置文件中?

更新:我设法将带有旧配置文件的 firefox 实例的“管理书签”菜单中的所有书签复制并粘贴到另一个同时打开新配置文件的实例中(使用命令行选项-no-remote)。但不幸的是,这仍然没有复制用于我的书签的标签,这也将是一个巨大的损失。

sqlite firefox bookmarks

4
推荐指数
1
解决办法
3853
查看次数

PostgreSQL-不存在PostgreSQL集群;服务重启期间请参阅“ man pg_createcluster”

我正在尝试停止已在Ubuntu服务器上运行的Postgresql 9.3数据库,但收到以下消息:

root@myprodserver:~# sudo /etc/init.d/postgresql stop

 * No PostgreSQL clusters exist; see "man pg_createcluster"
Run Code Online (Sandbox Code Playgroud)

如果我尝试列出集群,我将得到一个空结果:

root@myprodserver:~# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
Run Code Online (Sandbox Code Playgroud)

我试图运行一个createcluster:

root@myprodserver:~# pg_createcluster 9.3 main

Configuring already existing cluster (configuration: /etc/postgresql/9.3/main, data: /var/lib/postgresql/9.3/main, owner: 106:114)
Error: move_conffile: required configuration file /var/lib/postgresql/9.3/main/postgresql.conf does not exist

The database is up and running. The response shows that a cluster exists. I've restarted many times the service in the past without error messages.
Run Code Online (Sandbox Code Playgroud)

以下是结果sudo ps aux | …

database postgresql

4
推荐指数
1
解决办法
6424
查看次数

在 Atom 中创建多光标

我在带有 Wayland 窗口管理器的 Ubuntu 17.10 上使用 Atom。

我可以使用CTRL+Mousclick 或CTRL+创建多个光标d以选择下一个相同的字符串。

但是,例如,我如何标记一些行并在每行的开头创建一个光标?

使用搜索和查找全部在文本中选择大量结果以在所有这些结果上创建光标也很棒。

我目前通过选择换行符并使用CTRL+d使用额外的光标选择下一个换行符,然后向左走,Pos1 将光标置于每行的开头,从而使用了这种解决方法。

我想在一组输出的 3000 个文本块的数据集中选择一个重复约 200 次的字符串,然后我想将选择扩展到每个块。使用多个游标会很容易。我现在用另一种方式解决了这个问题,但下次我想看一本关于如何在标准原子设置中创建多个游标的完整说明手册。我找不到这个。搜索引擎在不同的多光标插件中为我提供了很多插件和解决方案。

atom-editor multiple-cursor

4
推荐指数
1
解决办法
772
查看次数

在 gnu Makefile 中组合多个 ifeq 和 ifneq

如果语法类似于,如何添加多个选择

ifeq ($(VAR1),some-string)
Run Code Online (Sandbox Code Playgroud)

结合

ifneq ($(VAR2),some-other-string)
Run Code Online (Sandbox Code Playgroud)

再加上一些……

有一个班轮吗?喜欢(幻想代码):

ifeq $VAR1=some-string and not $VAR2=some-other-string
Run Code Online (Sandbox Code Playgroud)

我发现这个答案我不清楚,因为那里的 ifeq 语句中没有等式。

makefile

4
推荐指数
1
解决办法
7628
查看次数

在 Dockerfile 中下载 git 存储库

每当我向 GitHub 存储库提交提交时,我都会使用 docker.com 自动构建。(参见https://docs.docker.com/docker-hub/builds/

我想调用luacheckdocker镜像中的所有文件,如果有警告就让它失败。

我故意添加了一个 Lua 错误,并在我的 中添加了这些行Dockerfile

RUN useradd -d /gluon gluon
RUN cd /gluon
RUN git clone https://github.com/rubo77/gluon/ gluon
RUN cd gluon

USER gluon

VOLUME /gluon
WORKDIR /gluon

RUN git checkout docker 
RUN cp -a docs/site-example/ site
RUN luacheckrc .; if [ $? -gt 0 ]; then exit 1; fi
Run Code Online (Sandbox Code Playgroud)

请参阅: https: //github.com/rubo77/gluon/commits/docker

但它失败了

/bin/sh: 1: cd: can't cd to /gluon
Run Code Online (Sandbox Code Playgroud)

甚至在 git 存储库之前

continuous-integration docker

4
推荐指数
1
解决办法
9504
查看次数

如何向SmartGit/hg添加全局gitignore?

我创建了一个全局.gitignore 文件(请参阅https://help.github.com/articles/ignoring-files#global-gitignore)但是如何在不将其添加到存储库的情况下将其用于SmartGit中的所有项目?

git smartgit

3
推荐指数
1
解决办法
7282
查看次数

向字段添加onchange事件侦听器

我想在onchange没有jquery 的情况下向这些输入字段添加一个事件:

<input type="text" id="cbid.wizard.1._latitude">
<input type="text" id="cbid.wizard.1._longitude">
Run Code Online (Sandbox Code Playgroud)

我已经可以调用该对象了

<script type="text/javascript">
    alert(document.getElementById('cbid.wizard.1._latitude').id);
</script>
Run Code Online (Sandbox Code Playgroud)

最后,我想添加这种行为,如果你在第一个输入中输入一对坐标,我会在两个输入字段上展开这对?

如何onchange使用javascript 添加活动?

javascript

3
推荐指数
1
解决办法
9762
查看次数

将图标添加到Redmine主题

redmine使用放置在 /usr/share/redmine/public/favicon.ico

我发现很多使用 cd /usr/share/redmine/; grep -HR favicon app/

app/helpers/application_helper.rb:  def favicon
app/helpers/application_helper.rb:    "<link rel='shortcut icon' href='#{favicon_path}' />".html_safe
app/helpers/application_helper.rb:  # Returns the path to the favicon
app/helpers/application_helper.rb:  def favicon_path
app/helpers/application_helper.rb:    icon = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
app/helpers/application_helper.rb:  # Returns the full URL to the favicon
app/helpers/application_helper.rb:  def favicon_url
app/helpers/application_helper.rb:    path = favicon_path
app/views/journals/index.builder:  xml.icon    favicon_url
app/views/common/feed.atom.builder:  xml.icon    favicon_url
app/views/layouts/base.html.erb:<%= favicon %>
Run Code Online (Sandbox Code Playgroud)

但要找到有关如何设置favicon_pathor的更多信息的运气就不好了favicon_url

解决方法:

我在主题文件夹中添加了一个小javascript javascripts/theme.js

document.head = document.head || document.getElementsByTagName('head')[0];

function changeFavicon(src) …
Run Code Online (Sandbox Code Playgroud)

favicon redmine

3
推荐指数
1
解决办法
2589
查看次数