我经常遇到的问题是,如果我转到使用php的服务器上的页面,则会收到“ 502 Bad Gateway”错误。
错误日志:
/var/log/nginx/error.log 每分钟显示大约3个此错误的副本:
2016/08/27 15:07:22 [error] 17309#0: *53554 connect() to unix:/var/run/php5-fpm.sock
failed (11: Resource temporarily unavailable) while connecting to upstream, client:
[dedicated server], server: localhost, request: "POST /xmlrpc.php HTTP/1.0",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: [my IP address]
Run Code Online (Sandbox Code Playgroud)
来自nginx或php5-fpm进程的CPU负载有时很巨大(超过100%),但有时却很明显(2%),很少那么微不足道。
我在syslog(!)中看到了很多东西:
Aug 27 15:17:21 [site] avahi-daemon[871]: Invalid response packet from host
[some IP address that isn't mine and nslookup never heard of].
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试过的事情:
apt-get updatephp5,php5-cgi和php5-fpmapache2系统上没有运行 …Visual Studio 2019 不会尝试编译我的 .cxx 或 .ixx 文件。这是我的 .cxx 文件:
export module greetings;
import std.core;
export std::string get_greeting_text()
{
return "Hello, World!";
}
Run Code Online (Sandbox Code Playgroud)
这是主要的:
import std.core;
import greetings;
int main()
{
std::cout << get_greeting_text() << '\n';
}
Run Code Online (Sandbox Code Playgroud)
我确实设置了这些标志:/std:c++latest, /experimental:module. 错误信息是
C:\...\main.cpp(2,17):error C2230: could not find module 'greetings'
C:\...\main.cpp(6,2): error C3861: 'get_greeting_text': identifier not found
Run Code Online (Sandbox Code Playgroud)
...但我没有看到任何关于尝试编译 greetings.cxx 的内容,所以这一定是问题所在。将其更改为 .ixx 无效。有什么解决办法?
下面的 MCVE 测试编译器(g++10)是否支持跨度,但给出了错误的答案。
#ifndef __cpp_lib_span
#warning "This compiler does not support spans."
#endif
#include <span>
int main(void)
{
int i[10];
std::span s(i);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它打印警告(如下),然后继续加载<span>和使用跨度。跨度似乎在不太小的程序中也能正常工作。g++ 很好地认识到它确实支持概念 ( __cpp_concepts)。我做错了什么,还是我发现了编译器错误?
main.cpp:2:2: warning: #warning "This compiler does not support spans." [-Wcpp]
2 | #warning "This compiler does not support spans."
Run Code Online (Sandbox Code Playgroud) 此 MCVE 在 Visual Studio 中运行良好。
#include <experimental/generator>
#include <iostream>
std::experimental::generator<int> f() { for (int i = 0; i < 10; ++i) co_yield i; }
int main ()
{
for (int i : f())
std::cout << i << ' ';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是在被列为完全支持或 C++20 的协程的 g++10 中,它没有。
(取出experimental并没有帮助。)
我正在编译:g++ -g -std=c++2a -fcoroutines -c main.cpp。
它抱怨没有包含文件生成器,如果我取出#include,该生成器不是 std:: 的一部分或未定义。我想在新标准中它还有另一个名字吗?或者,如果没有,我该怎么做才能获得使用 的协程co_yield?
在XNA中有类似的问题System.Drawing,但这可能是一个更清晰的问题,因此更容易回答.
我们试图在C#中在屏幕上画线.我们正在使用XNA库.这段代码
void DrawLine2 (Vector2 point1, Vector2 point2)
{
System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Green, 1);
Point p1 = new Point((int)point1.X, (int)point1.Y), p2 = new Point((int)point2.X, (int) point2.Y);
Graphics.DrawLine (pen, p1, p2);
}
Run Code Online (Sandbox Code Playgroud)
给出了Graphics不存在的编译时错误.
也许我应该在XNA中使用某些东西来绘制线而不是在系统中 - 但如果是这样,我不确定是什么.XNA有一个Spritebatch绘图功能,但AFAIK你给它一个精灵和一个中心(和一个旋转),而不是2点.
In the for loop below:
struct Block
{
Block(int d) : data(d), next(nullptr) {}
int data;
Block* next;
};
Block* aList = new Block(1);
Block* bList = new Block(2);
for (Block* a = aList, *b = bList; a != nullptr; a = a->next, b = b->next)
if (aList->data != bList->data)
cout << "Difference found.\n";
Run Code Online (Sandbox Code Playgroud)
I don't like putting the * before b, but of course it's needed to distinguish Block from Block*. Is there another way to do this? for …
此处的代码抱怨带有 push_back 的行试图创建抽象类型的对象。
#include <vector>
#include <memory>
class Abstract
{
public:
Abstract() {}
virtual void f() = 0;
};
class Derived : public Abstract
{
public:
Derived() {}
void f() override { }
};
int main (int argc, char** argv)
{
std::vector<std::unique_ptr<Abstract>> vec;
vec.push_back (std::make_unique<Abstract>(new Derived));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
以下是错误消息:
error C2259: 'Abstract': cannot instantiate abstract class
Run Code Online (Sandbox Code Playgroud)
我以为unique_ptr只会拿指针而无需考虑它指向的内容?
c++ ×5
c++20 ×3
c# ×1
c++-modules ×1
coroutine ×1
fpm ×1
g++ ×1
nginx ×1
unique-ptr ×1
visual-c++ ×1
xna ×1