In Peskin and Schroeder, I have a problem with a claim in equation (2.54), which I will rewrite more concisely here. He claims that we have the following equality :
$$ \frac{1}{2E_p}e^{-iE_p(x_0)}-\frac{1}{2E_p}e^{iE_p(x_0)} = \int\frac{dp_0}{2\pi i}\frac{-1}{(p_0-E_p)(p_0+E_p)}e^{-ip_0x_0}.\tag{2.54} $$
Where $x_0 > 0, E_p>0$ and the complex integral should be carried along a contour that avoids with semi-circles "from above" the two singularities at $E_p$, and $-E_p$, and closing it from below.
Now, I have two problems with that. First of all, it seems in his book he takes into account only the contributions of the residues, which give exactly the equation above. However, when doing carefully the integration along the small semicircles around the poles, we find that they both contribute, so that we obtain the right expression only up to a factor of 2, i.e.:
$$\int\frac{dp_0}{2\pi i}\frac{-1}{(p_0-E_p)(p_0+E_p)}e^{-ip_0x_0} = -2\pi i(\frac{1}{2E_p*2\pi i}e^{-iE_p(x_0)}-\frac{1}{2E_p*2\pi i}e^{iE_p(x_0)})+\pi i(\frac{1}{2E_p*2\pi i}e^{-iE_p(x_0)}-\frac{1}{2E_p*2\pi i}e^{iE_p(x_0)}) = \frac{1}{4E_p}e^{-iE_p(x_0)}-\frac{1}{4E_p}e^{iE_p(x_0)}.$$
And this is done with the integration contour that he states, only it seems that he doesn't take into account the contribution of the small semicircles.
I think the problems stems from the fact that this integral is actually divergent, since we have first order poles on the real axis, so we need a prescription to regularise it. The one I did here, and the one he seems to be doing in his book, is using the principal value.
What I think he actually should have said in his book is that the prescription is the following:
$$\int\frac{dp_0}{2\pi i}\frac{-1}{(p_0-E_p+i\epsilon)(p_0+E_p+i\epsilon)}e^{-ip_0x_0}.$$
So that the poles are move from the real axis and then we don't have any contribution from the small semicircles.
Is this assumption right? Or have I somehow misunderstood/miscalculated Peskin's prescription?
P.S.: Since it was added in the comments, I detail here the semi-circle contribution, in case it is useful (which is, as stated in the answer, convergent ONLY if we take the principal value of the integral)
Let us do the integration along the semi-circle around $E_p$. The parametrisation is $z = E_p+\epsilon e^{i\theta}$ with $\theta \in [\pi,0]$(Note that in this parametrisation we implicitly took the principal value since the integration is symmetric around the pole). Writing the integral we obtain:
$$\int \frac{i \epsilon e^{i\theta}d\theta}{2\pi i} \frac{-1}{\epsilon e^{i\theta}(2E_p+\epsilon e^{i\theta})}\exp{\left(-i(E_p+\epsilon e^{i\theta})\right)}\\ = i\int_\pi^0 \frac{d\theta}{2\pi i} \frac{-1}{(2E_p+\epsilon e^{i\theta})}\exp{\left(-i(E_p+\epsilon e^{i\theta})\right)}.$$
Doing the series expansion in $\epsilon$ we see that all the terms that are of the form $e^{in\theta}$ vanish in the integration, so we can consider only the constant term which yields:
$$i\int_\pi^0 \frac{d\theta}{2\pi i} \frac{-1}{(2E_p)}e^{-i(E_p)} = \frac{1}{4E_p}e^{-iE_p}.$$